moby: .dockerignore makes sending context to daemon super slow

Our project is total of 611.6MB, without .dockerignore file, takes 2.7s to build: docker -D build . 2.69s user 4.65s system 25% cpu 28.609 total

With a single **/.DS_Store line in .dockerignore, takes 14.44s docker -D build . 14.44s user 6.08s system 60% cpu 33.767 total

With a .gitignore like .dockerignore 30 lines file, take 154.46s docker -D build . 154.46s user 18.81s system 123% cpu 2:20.58 total

All build steps are using cache. Initially I thought docker build hang since no input was printed out for a while, only know it’s working when using -D option with build.


BUG REPORT INFORMATION

Output of docker version:

Client:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 21:20:08 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   56888bf
 Built:        Mon Jun  6 23:57:32 2016
 OS/Arch:      linux/amd64

Output of docker info:

Containers: 4
 Running: 0
 Paused: 0
 Stopped: 4
Images: 34
Server Version: 1.11.2
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 146
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge null host
Kernel Version: 4.4.12-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.857 GiB
Name: moby
ID: I6RW:LBCE:RPM3:RRIZ:AVD6:3Z4G:T2XA:VFAH:Q7UO:5QY3:PHAF:JI3Y
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): true
 File Descriptors: 19
 Goroutines: 38
 System Time: 2016-06-12T08:34:18.683765291Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/

Additional environment details (AWS, VirtualBox, physical, etc.):

Docker for Mac: version: mac-v1.11.2-beta15
OS X: version 10.11.5 (build: 15F34)
logs: /tmp/20160612-163816.tar.gz
failure: No error was detected
[OK]     docker-cli
[OK]     app
[OK]     menubar
[OK]     virtualization
[OK]     system
[OK]     osxfs
[OK]     db
[OK]     slirp
[OK]     moby-console
[OK]     logs
[OK]     vmnetd
[OK]     env
[OK]     moby
[OK]     driver.amd64-linux

Steps to reproduce the issue:

  1. Inside a non-trivial project, a Dockerfile with a single line: FROM ruby:2.3.0
  2. Edit .dockerignore file to compare 3 cases above

Describe the results you received: Longer .dockerignore file make project a lot slower/

Describe the results you expected: .dockerignore file should help sending context faster

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 7
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Seeing this issue still with Docker version 17.03.0-ce, build 60ccb22

dockerigore file is making our build ~30x slower…

+1 I also notice disproportional increases in time with more dockerignore entries. In a recent experiment, we tried ignoring all static files in order to get down the size of the layer (they are not necessary for the backend image) and the build time jumped from 3 minutes to 15 minutes, while decreasing the layer size from 380mb to 250mb. Not worth it.

We ended up scrapping use of dockerignore altogether and instead using an rsync filter rules file to rsync all files to be included in the docker build to a separate directory, then building from there. The build context is just as small, but build times are now around 30 seconds including the rsync-step.

Just to mention this duplicate I just filed: https://github.com/docker/docker/issues/26816

And work I started in the past (but don’t have time to finish) which made docker build ~100x more CPU efficient for me: https://github.com/docker/docker/pull/20128.