I have a local volume created in docker
when i run the following command the content inside volumes as successfully copied to the docker container
docker run -d \
--name devtest \
--mount source=mydata,target=/var/www/admin/public \
local:5000/api-live/php-fpm:2021-04-22-07.19.24
However when i try to do the same in docker-compose the contents dont get copied just the Destination folder is created
services:
fpm:
image: local:5000/api-live/php-fpm:2021-04-22-07.19.24
ports:
- "9090:9000"
volumes:
- ./mydata:/var/www/admin/public
restart: always
Thanks in advance for helping
When the volume has been already created, which is deduced through the first docker
command with bind --mount
switch , you have to specify such a state to docker compose in order for the latter to not create a new volume named after your project name ( [project_name]_mydata .
This can be achieved using the external: true
volume property:
services:
fpm:
image: local:5000/api-live/php-fpm:2021-04-22-07.19.24
ports:
- "9090:9000"
volumes:
- mydata:/var/www/admin/public
restart: always
volumes:
mydata:
external: true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.