Reputation: 2543
Imagine a project folder like this:
Now, if
Dockerfile
contains an instruction ADD . /code/
, and docker-compose.yml
file configures a service that uses the docker_volume_folder
in its volume mapping, can I then add the docker_volume_folder
in the .dockerignore
file, to prevent that the volume folder is copied to the docker container by the ADD . /code/
instruction in the dockerfile?
I think adding the docker volume folder to the docker container is not only useless, maybe it's even dangerous. However, I want to avoid that Docker Compose does not want to create the volume, since it is mentioned in the .dockerignore
file.
I can't find information about volumes in the dockerignore in the documentation.
Upvotes: 1
Views: 1798
Reputation: 264236
You can include the directory in your .dockerignore file, that only affects the build, not the later volume mounts.
The only reason you may want to include the directory inside your image is if you want named volumes to be initialized with the contents of the image. If you only use host volumes, this will not be an issue.
Upvotes: 3