How to test dockerignore file?
How do I check my dockerfile ignore the correct files and directories?
3 Solutions collect form web for “How to test dockerignore file?”
To expand on VonC’s suggestion, here’s a sample
dockerfile and build/run commands you can use to create a container with the current folders build context:
$ cat >df.build-context <<EOF FROM busybox COPY . /build-context WORKDIR /build-context CMD find . EOF
docker build -f df.build-context -t my-build-context . docker run --rm -it my-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 and not ignored by your
Note: that the change in name for the Dockerfile is to avoid overwriting your existing project’s
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
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.