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?
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 (named Dockerfile.build-context
to avoid conflicting with your project's Dockerfile
):
FROM busybox
COPY . /build-context
WORKDIR /build-context
CMD find .
Once created, execute these commands in the command line:
docker build -f Dockerfile.build-context -t build-context .
docker run --rm -it build-context
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.
To get a detailed analysis of the build context you could use pwaller/docker-show-context.
$ go get -v -u github.com/pwaller/docker-show-context
$ cd ~/path/to/project/using/docker
$ docker-show-context
It outputs statistics about the build such as file sizes and upload times.
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
.