I have a docker-compose file which describes several services. All services have volumes attached to them, however only one has the volume named. When I run docker compose down
I want to automatically delete the not named volumes while at the same time create all volumes that are missing.
services:
service1:
image: some/image:1
volumes:
- named-volume:/home/user1
service2:
image: some/image:2
#volumes: not declared volumes that are named automatically with a hash
volumes:
named-volume:
name: volume-for-service1
The first time I run docker compose up
I want to automatically create all volumes (named and unnamed) and when I run docker compose down
I want that unnamed volumes to be deleted while the named one (volume-for-service1
) to be preserved. Next time I run docker compose up
it should only create the unnamed volumes as the named one already exists.
I have tried:
docker compose down -v
which removed no volumedocker compose down --remove-orphans
which removed no volumedocker compose down --rmi local
which removed no volumedocker-compose down -v
which removed the named volumedocker-compose down --remove-orphans
which removed no volumedocker-compose down --rmi local
which removed no volume
OS: Windows 10 x64
I don't quite get it. What command should I run to achieve desired results?
docker-compose.yml
? – Abbate