Answer the question
In order to leave comments, you need to log in
Using volume in docker-compose?
I would be glad if someone explains in simple terms some incomprehensible moments of using volume in docker-compose.
Why is the last directive needed in this docker-conpose, what specific role does it play:
volumes:
db-data:
- db-data:/var/lib/mysql/data
version: "3.7"
services:
wordpress:
image: wordpress
ports:
- "8080:80"
networks:
- overlay
deploy:
mode: replicated
replicas: 2
endpoint_mode: vip
mysql:
image: mysql
volumes:
- db-data:/var/ lib/mysql/data
networks:
- overlay
deploy:
mode: replicated
replicas: 2
endpoint_mode: dnsrr
volumes:
db-data:
Answer the question
In order to leave comments, you need to log in
The last directive is needed to declare your own volume (volume), which will be created when the services are first started. Under each definition, you can add more options for this volume. For example, to declare that it is external and should have already been created manually in advance:
volumes:
db-data:
external: true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question