How to test dockerignore file?

After reading the .dockerignore documentation, I’m wondering if there is a way to test it?



How do I check my dockerfile ignore the correct files and directories?

  • Running docker-maven-plugin on the very end of parent pom building
  • Docker Issue -Image State not getting saved
  • Docker automated build Error: Build failed: Dockerfile not found at ./Dockerfile
  • How to mount a folder in a container as locally
  • How to run a docker container which acts as a proxy/gateway?
  • Why are environment variables not being set inside of my docker container?
  • supervisor curl command failing with exit 56 error
  • Docker - MySQL commands within Dockerfile using RUN (ERROR 2002)
  • How to run a docker container as a daemon starting the rails project built inside?
  • How to use gpicview inside docker?
  • Docker global variable unavailable in Jenkins pipeline
  • Can't access docker over the internet
  • 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 > <<EOF
    FROM busybox
    COPY . /build-context
    WORKDIR /build-context
    CMD find .


    docker build -f -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 .dockerignore file.

    Note: that the change in name for the Dockerfile is to avoid overwriting your existing project’s Dockerfile.

    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.

    $ go get -v -u
    $ cd ~/path/to/project/using/docker
    $ docker-show-context

    It outputs statistics about the build such as file sizes and upload times.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.