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?

  • How to setup git and git-sync in a docker container?
  • Exposing ports to all containers, not only the host
  • Ansible Docker Container - Clone Private Repo
  • How to Enable Systemd service in openshift/jenkins-1-centos7 docker container?
  • How to initialize and run Docker on windows?
  • How to import .bacpac into docker Sqlserver?
  • Use custom Visual Studio run configuration with Docker
  • Build a Docker Image from private git repository
  • Docker routing/reverse proxy issue, can't curl other container
  • using smart_open lib with a s3 docker image
  • Akka and Docker on Marathon
  • ElasticSearch on Elastic Beanstalk
  • 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.