N
N
nathan1117772021-10-09 17:57:57
Drupal
nathan111777, 2021-10-09 17:57:57

What needs to be written in volumes to store the Drupal database not only in the container but also on the computer?

I have Ubuntu 18.04 OS. I downloaded Drupal9 to my desktop using: composer create-project drupal/recommended-project project_name. I will raise the Drupal project using the Docker-based Drupal stack , and after running the images and writing in the url: projectname.localhost:8000 , the Drupal installation window will start.

But before that, I need to uncomment volumes in the docker-compose.yml file in the part of the code that belongs to mariadb and write something to store the Drupal database not only in the container but also on the computer. I don't know exactly what to write.

services:
  mariadb:
    image: wodby/mariadb:$MARIADB_TAG
    container_name: "${PROJECT_NAME}_mariadb"
    stop_grace_period: 30s
    environment:
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD
#    volumes:
#      - ./mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here.
#      - /path/to/mariadb/data/on/host:/var/lib/mysql # Use bind mount


# Place init .sql file(s) here.

Do I need to write the path to some .sql file? How to find out where he is? And how to initialize it?

# - /path/to/mariadb/data/on/host:/var/lib/mysql # Use bind mount

What should be written in this line? I only have mysql installed on my computer. Mariadb is not. After all, the point of docker is not to install or configure anything in your OS, and before docker just installed mariadb in a container.

Where exactly to store the database on my computer does not matter to me. The main thing is that if the data in the container is lost for some reason, I can take it from my computer.
Perhaps someone has already worked with docker4drupal and can give an example of what you wrote in volumes in your project.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2021-10-09
@nathan111777

Usually something like this is enough to write:

...
    volumes:
        - ./db:/var/lib/mysql
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question