Docking volumes of MariaDB Windows

I am trying to run a Dockerize and Open Source project that I created in my second year at college, this project uses MariaDB, phpMyAdmin and the PHP / Yii Framework.

My goal is to make it ready to use using just a simple docker-compose up command.

I managed to establish a connection between phpMyAdmin and DB, and now I'm stuck on trying to get Docker for the relative path to the database volume in order to make it consistent.

Here is what I have regarding volume setting:

 volumes: - './database/mysql/:/var/lib/mysql' 

This is storing database files inside the project, and then I can ignore these files in .gitignore The problem is that when I launch docker-compose up with this configuration, I get:

Invalid volume specification: 'C:\Users\MySelf\coding\my_app\database\mysql:/var/lib/mysql:rw'

As for the host, I use Windows with the Docker Toolbox, but I want docker-compose.yml work regardless of the OS.

I saw other similar questions, but their error came from problems with absolute paths in Windows that I am not looking for.

EDIT: adding the correct final docker-compose.yml file, hope it can help

 version: '2' services: web_db: build: ./database/mysql command: "mysqld --innodb-buffer-pool-size=20M" volumes: - ./database/mysql/data/:/var/lib/mysql - ./database/mysql/initDB/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql environment: MYSQL_ROOT_PASSWORD: 'YOURPASSWORD' MYSQL_DATABASE: 'support-technique' MYSQL_ROOT_HOST: '172.17.0.1' ports: - "3306:3306" container_name: web_db web: build: . depends_on: - web_db links: - web_db:db ports: - "80:80" phpmyadmin: image: phpmyadmin/phpmyadmin depends_on: - web_db links: - web_db:mysql ports: - "8181:80" environment: PMA_HOST: mysql 
+5
source share
1 answer

When you set the host directory as the data volume , the documentation says:

host-dir can be an absolute path or value of a name. If you specify an absolute path for host-dir , bind the Docker bindings to the path you specify. If you specify a name, Docker will create a named volume under that name.

The name value must begin with an alphanumeric character followed by a-z0-9 , _ (underscore) a-z0-9 (period) or - (hyphen).
The absolute path starts with / (slash).

This explains the error message.

Using an absolute path associates it with the OS (this is not what you want)

 docker run -vc:\<path>:/c:\<container path> docker run -v /c/<path>:/c:\<container path> 

As mentioned in the “ Getting Started” example running docker “Invalid volume specification” on Windows, “try setting this docker-compose environment variable first:

Create the .env file in the docker-compose.yml path hosted with the following contents:

 COMPOSE_CONVERT_WINDOWS_PATHS=1 

OP Daniel confirms in the comments that with .env including COMPOSE_CONVERT_WINDOWS_PATHS , the relative path works .

I would recommend using a data volume instead: it will not depend on the host name.

+4
source

Source: https://habr.com/ru/post/1261939/


All Articles