Dockerfile vs. docker-compose VOLUME

Solution 1:

A VOLUME instruction in the dockerfile creates a mount point but initially only maps it to Docker's internal data directory.

In order to map the volume to the host filesystem, you need to specify which path on the host should be mapped to the volume. You can do this in the docker-compose file using the volumes parameter. (Note: you can create volumes using docker-compose without declaring them in the Dockerfile.)

Note that when mapping a directory from the host to a container, the directory contents on the host will replace the contents in the container, not vice versa.