Docker Community Forums

Share and learn in the Docker community.

Can I specify the directory where named containers are created?


(Hhue13) #1

I’m using a docker-compose v2 file which looks like the following:
— snip —
services:

svc:
container_name: svc-derby.acme.com
entrypoint: /bin/startContainer.sh
hostname: svc-derby.acme.com
image: docker.acme.com:5000/centos_wp:8.5.9.10.10.derby
networks:
wp_bridge_network_int:
aliases:
- svc-derby.acme.com
ports:
- 10041:10041
- 10039:10039
volumes:
- svc_derby_profile_volume:/acme/wp_profile

networks:
wp_bridge_network_int:
driver: bridge

volumes:
svc_derby_profile_volume:
external: false
— snip —

This file works nicely and creates the named container svc_derby_profile_volume if it does not already exist when compose is started. BUT the volume is created in the default location /var/lib/docker/volumes.

The qustions now is: Is there a way to change the compose file in a way that the named container svc_derby_profile_volume is created at a different location which can be defined in the compose file?