Image & Compose Volume Declarations
If a Dockerfile specifies a VOLUME
at a particular location:
VOLUME /my/cool/data/nested-data
And then in a docker compose file, you attempt to mount a parent directory:
services:
my_service:
image: docker/linux:latest
volumes:
- './data:/my/cool/data'
If you were intending to have the nested-data
volume nested under the ./data
directory, this
will NOT do that. Instead, you will end up with a separate, dynamically created volume that will
be in a different location. To actually map a local directory for the nested-data
volume, you'll
need to explicitly include that in the docker-compose service definition:
services:
my_service:
image: docker/linux:latest
volumes:
- './data:/my/cool/data'
- './data/nested-data:/my/cool/data/nested-data'