Sander Vanden Hautte
Sander Vanden Hautte

Reputation: 2543

Can a .dockeringore file include a volume folder?

Imagine a project folder like this:

Now, if

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

Answers (1)

BMitch
BMitch

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

Related Questions