🌐
GitHub
github.com › topics › dockerignore
dockerignore · GitHub Topics · GitHub
A Go-based CLI to generate .dockerignore files, inspired by gibo.
🌐
GitHub
github.com › docker › docs › blob › main › .dockerignore
docs/.dockerignore at main · docker/docs
Source repo for Docker's Documentation. Contribute to docker/docs development by creating an account on GitHub.
Author   docker
🌐
GitHub
gist.github.com › KernelA › 04b4d7691f28e264f72e76cfd724d448
.dockerignore example for Python projects · GitHub
.dockerignore example for Python projects. GitHub Gist: instantly share code, notes, and snippets.
🌐
GitHub
github.com › roadiz › standard-edition › blob › master › .dockerignore
standard-edition/.dockerignore at master · roadiz/standard-edition
April 17, 2024 - .dockerignore · .DS_Store · .git · .github · .gitignore · .gitlab-ci.yml · .gitmodules · .idea · .data · .sass-cache · tests · README.md · Dockerfile · Dockerfile.archive · docker-compose.yml · · */temp* */*/temp* docker · .vagrant · .data ·
Author   roadiz
🌐
GitHub
github.com › starlightromero › dockerignore-example
GitHub - starlightromero/dockerignore-example: How to use .dockerignore to the fullest potential · GitHub
Dockerignore Example serves to show how .dockerignore files work and the benefits of using them, along with various examples.
Starred by 2 users
Forked by 4 users
Languages   Go 53.3% | Makefile 25.1% | Dockerfile 20.7% | Shell 0.9%
🌐
GitHub
github.com › sameersbn › docker-gitlab › blob › master › .dockerignore
docker-gitlab/.dockerignore at master · sameersbn/docker-gitlab
Dockerized GitLab. Contribute to sameersbn/docker-gitlab development by creating an account on GitHub.
Author   sameersbn
🌐
GitHub
github.com › balena-io-modules › dockerignore
GitHub - balena-io-modules/dockerignore: dockerignore is a file filter library compatible with Docker and the node-ignore API · GitHub
dockerignore is a file filter library compatible with Docker and the node-ignore API - balena-io-modules/dockerignore
Author   balena-io-modules
🌐
GitHub
github.com › getsentry › action-release › blob › master › .dockerignore
action-release/.dockerignore at master · getsentry/action-release
# Docs: https://docs.docker.com/engine/reference/builder/#dockerignore-file · # These files will be ignore by Docker for COPY and ADD commands when creating a build context · # In other words, if a file should not be inside of the Docker container ...
Author   getsentry
🌐
GitHub
github.com › BretFisher › node-docker-good-defaults › blob › main › .dockerignore
node-docker-good-defaults/.dockerignore at main · BretFisher/node-docker-good-defaults
sample node app for Docker examples. Contribute to BretFisher/node-docker-good-defaults development by creating an account on GitHub.
Author   BretFisher
🌐
GitHub
gist.github.com › yizeng › eeeb48d6823801061791cc5581f7e1fc
An example .dockerignore file for Rails · GitHub
An example .dockerignore file for Rails. GitHub Gist: instantly share code, notes, and snippets.
Find elsewhere
🌐
GitHub
github.com › moby › moby › blob › master › .dockerignore
moby/.dockerignore at master · moby/moby
The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems - moby/.dockerignore at master · moby/moby
Author   moby
🌐
GitHub
github.com › verdaccio › verdaccio › blob › master › .dockerignore
verdaccio/.dockerignore at master · verdaccio/verdaccio
September 11, 2020 - # https://docs.docker.com/engine/reference/builder/#dockerignore-file
Author   verdaccio
🌐
GitHub
github.com › codeskyblue › dockerignore
GitHub - codeskyblue/dockerignore: go library parse gitignore file, source code most from docker · GitHub
go library parse gitignore file, source code most from docker - codeskyblue/dockerignore
Starred by 13 users
Forked by 3 users
Languages   Go
🌐
GitHub
github.com › balena-io-modules › dockerignore › blob › master › README.md
dockerignore/README.md at master · balena-io-modules/dockerignore
dockerignore is a file filter library compatible with Docker and the node-ignore API - dockerignore/README.md at master · balena-io-modules/dockerignore
Author   balena-io-modules
🌐
GitHub
github.com › gothinkster › aspnetcore-realworld-example-app › blob › master › .dockerignore
aspnetcore-realworld-example-app/.dockerignore at master · gothinkster/aspnetcore-realworld-example-app
ASP.NET Core backend implementation for RealWorld. Contribute to gothinkster/aspnetcore-realworld-example-app development by creating an account on GitHub.
Author   gothinkster
🌐
GitHub
github.com › codeskyblue › dockerignore › blob › master › README.md
dockerignore/README.md at master · codeskyblue/dockerignore
go library parse gitignore file, source code most from docker - dockerignore/README.md at master · codeskyblue/dockerignore
Author   codeskyblue
Top answer
1 of 1
57

It suffices to use the ** pattern. For example:

.dockerignore

**/.git

The relevant passage from that page of the official doc is:

.dockerignore file

[…]

Matching is done using Go’s filepath.Match rules. A preprocessing step removes leading and trailing whitespace and eliminates . and .. elements using Go’s filepath.Clean. Lines that are blank after preprocessing are ignored.

Beyond Go’s filepath.Match rules, Docker also supports a special wildcard string ** that matches any number of directories (including zero). For example, **/*.go will exclude all files that end with .go that are found in all directories, including the root of the build context.

[…]

Working example

Here is a complete session with Docker CE under Debian GNU/Linux:

$ docker version
Client:
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        6247962
 Built:             Sun Feb 10 04:13:52 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 03:42:13 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Consider the following working directory:

$ tree -a
.
├── a
│   ├── .git
│   │   └── c
│   └── go
│       └── 1
├── b
│   ├── c
│   │   ├── .git
│   │   │   └── c
│   │   └── go
│   │       └── 1
│   ├── .git
│   │   └── c
│   └── go
│       └── 1
├── Dockerfile
├── .dockerignore
├── .git
│   └── c
└── go
    └── 1

And the following source files:

$ cat .dockerignore
**/.git

$ cat Dockerfile
FROM debian

WORKDIR /app

COPY . .

CMD ls -Rhal

Then I get:

$ docker build -t test .
[…]

$ docker run --rm -it test 
.:
total 28K
drwxr-xr-x 1 root root 4.0K Feb 20 19:40 .
drwxr-xr-x 1 root root 4.0K Feb 20 19:43 ..
-rw-r--r-- 1 root root    8 Feb 20 19:38 .dockerignore
-rw-r--r-- 1 root root   50 Feb 20 19:40 Dockerfile
drwxr-xr-x 3 root root 4.0K Feb 20 19:39 a
drwxr-xr-x 4 root root 4.0K Feb 20 19:39 b
drwx------ 2 root root 4.0K Feb 20 19:40 go

./a:
total 12K
drwxr-xr-x 3 root root 4.0K Feb 20 19:39 .
drwxr-xr-x 1 root root 4.0K Feb 20 19:40 ..
drwxr-xr-x 2 root root 4.0K Feb 20 19:39 go

./a/go:
total 8.0K
drwxr-xr-x 2 root root 4.0K Feb 20 19:39 .
drwxr-xr-x 3 root root 4.0K Feb 20 19:39 ..
-rw-r--r-- 1 root root    0 Feb 20 19:39 1

./b:
total 16K
drwxr-xr-x 4 root root 4.0K Feb 20 19:39 .
drwxr-xr-x 1 root root 4.0K Feb 20 19:40 ..
drwxr-xr-x 3 root root 4.0K Feb 20 19:39 c
drwxr-xr-x 2 root root 4.0K Feb 20 19:39 go

./b/c:
total 12K
drwxr-xr-x 3 root root 4.0K Feb 20 19:39 .
drwxr-xr-x 4 root root 4.0K Feb 20 19:39 ..
drwxr-xr-x 2 root root 4.0K Feb 20 19:39 go

./b/c/go:
total 8.0K
drwxr-xr-x 2 root root 4.0K Feb 20 19:39 .
drwxr-xr-x 3 root root 4.0K Feb 20 19:39 ..
-rw-r--r-- 1 root root    0 Feb 20 19:39 1

./b/go:
total 8.0K
drwxr-xr-x 2 root root 4.0K Feb 20 19:39 .
drwxr-xr-x 4 root root 4.0K Feb 20 19:39 ..
-rw-r--r-- 1 root root    0 Feb 20 19:39 1

./go:
total 8.0K
drwx------ 2 root root 4.0K Feb 20 19:40 .
drwxr-xr-x 1 root root 4.0K Feb 20 19:40 ..
-rw-r--r-- 1 root root    0 Feb 20 19:40 1
🌐
GitHub
github.com › dotnet › runtime › blob › main › .dockerignore
runtime/.dockerignore at main · dotnet/runtime
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps. - runtime/.dockerignore at main · dotnet/runtime
Author   dotnet