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

  • Is it possible to access the entry command bash on a running docker container?
  • Create a volume in docker from windows host
  • Reducing docker image size
  • Run docker from console
  • How to run tests on CentOS 7 with Travis-CI?
  • What's the best practice for including a .env file in a jenkins build?
  • *
    ^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 compose using environment variables to set extra host
  • How to delete all tagged docker images?
  • how to retrieve volume from a removed Docker container?
  • Rails app under Docker - how to handle container dependencies?
  • Handshake Exception in Liberty Profile with Docker
  • Create docker base image for a linux iso image
  • 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.