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.

.dockerfile

  • 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`
  • *
    ^Dockerfile
    ^web-app/dist
    

    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 ?

    Thanks

  • 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:

    */temp*
    */*/temp*
    temp?
    *.md
    !LICENSE.md
    

    The line !LICENSE.md will cause LICENSE.md 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.