Docker Community Forums

Share and learn in the Docker community.

Docker-compose.yml V3 and volumes


(Nicoxnoise) #1

hello everybody,

It does ten days i’m studying dokcer and i get a test environnement:
-2 VM: swarm management + worker
-1VM: local registry with nginx authentication proxy.

All seems to work, i deploy multiple stack (apache/php/mysql) and i can reach my web applications.

I deploy stack from a docker-compose.yml file.

And there is a point where i get real troubles (it’s for this i come to you today): the volumes.

I really get trouble with this point…
Here a working docker-compose.yml file:

version: "3"
services:
web:
image: nimmis/apache-php7
volumes:
- ./php-sources:/var/www/html
ports:
- "8180:80"
deploy:
replicas: 2
mysql:
image: mysql/mysql-server:5.6
volumes:
- mysqldata:/var/lib/mysql
ports:
- "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: azertystack
deploy:
replicas: 2
volumes:
php-sources:
mysqldata:

I use 2 volumes:
./php-sources (bind): directory simply creaet on host, in the same ddirectory than the docker-compose.yml file
mysqldata (volume): a volume create with the command: docker volume create mysqldata

When i inspect my mysql container mysql/mysql-server:5.6 here what i get:
“Mounts”: [
{
“Type”: “volume”,
“Name”: “wordpressenv_mysqldata”,
“Source”: “/var/lib/docker/volumes/wordpressenv_mysqldata/_data”,
“Destination”: “/var/lib/mysql”,
“Driver”: “local”,
“Mode”: “z”,
“RW”: true,
“Propagation”: “”
}
],

Forever i have a volume mysqldata but it doesn’t seem to be used:
#> docker volume ls
DRIVER VOLUME NAME
local mysqldata

and i have too a volume named:
DRIVER VOLUME NAME
local wordpressenv_mysqldata

So here my question:
What is the exact syntaxe in my docker-compose.yml file for the volumes ?
Why this is not the mysqldata volune that is used as i configure in my docker-compose.yml file ?

Thanks a lot in advance for you help