After reading the .dockerignore
documentation, I'm wondering if there is a way to test it?
Examples
**/node_modules/
How do I check my dockerfile ignore the correct files and directories?
After reading the .dockerignore
documentation, I'm wondering if there is a way to test it?
**/node_modules/
How do I check my dockerfile ignore the correct files and directories?
One way is to make a small Dockerfile with an ADD or COPY directive in it.
Try to add or copy a file in a
node_modules
folder: it is does not succeed, that would be because of the.dockerignore
.To get a detailed analysis of the build context you could use pwaller/docker-show-context.
It outputs statistics about the build such as file sizes and upload times.
To expand on VonC's suggestion, here's a sample
Dockerfile
and set of build/run commands you can use to create a container with the current folder's build context (namedDockerfile.build-context
to avoid conflicting with your project'sDockerfile
):Once created, execute these commands in the command line:
When you copy/paste the above to a prompt, the
run
command will output the files that were copied to the Docker host that are not ignored by your.dockerignore
file.