is there a way to negate a pattern in .dockerignore?

I am trying to negate a pattern in a .dockerignore. The Globbing is done using Go’s filepath.Match rules. After checking the source, it seems we can negate a pattern by using ^ character.


  • Docker access elasticsearch endpoint from host
  • Unable to use the “Docker push” command with ECR
  • Vagrant docker chef_solo provision fail on CentOS and SuSe linux
  • How to check if a voip server setup on docker is working or not?
  • Handling cron jobs in docker?
  • Dockerfile CMD `command not found`
  • *

    However, when i docker build, I have the following error:

    Dockerfile was excluded by .dockerignore pattern '*'

    Do you know if its possible to accomplish what I want ?


  • Docker Remote API Filter Exited
  • Updating Docker, Docker Machine, Docker Compose
  • Docker MEAN stack which FROM to use?
  • Docker retain ENV variables
  • Docker machine unable to start the remote machine
  • Kitematic: connecting to a docker machine with different name
  • One Solution collect form web for “is there a way to negate a pattern in .dockerignore?”

    As of version 1.7.0, this is now possible.

    Negating with ! now works as you would expect and is documented in the official Dockerfile reference.

    Here’s an example taken from the link above:


    The line ! will cause to be included in the Docker build context despite the *.md rule.

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