Docker build lag


docker-compose build

lags, then chances are you’ve forgotten to ignore some node_modules or there’s massive files it’s trying to bundle up.


docker-compose --verbose build

and it’ll show you extra debug information.

$> docker-compose --verbose build
compose.config.config.find: Using configuration files: .\docker-compose.yml
docker.auth.find_config_file: Trying paths: ['C:\\Users\\user\\.docker\\config.json', 'C:\\Users\\user\\.dockercfg']
docker.auth.find_config_file: Found file at path: C:\Users\user\.docker\config.json
docker.auth.load_config: Found 'credsStore' section
compose.cli.command.get_client: docker-compose version 1.14.0, build c7bdf9e3
docker-py version: 2.3.0
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.2j 26 Sep 2016
compose.cli.command.get_client: Docker base_url: http+docker://localnpipe
compose.cli.command.get_client: Docker version: KernelVersion=4.9.41-moby, Arch=amd64, BuildTime=2017-08-17T22:54:55.996274355+00:00, ApiVersion=1.30, Version=17.06.1-ce, MinAPIVersion=1.12, GitCommit=874a737, Os=linux, Experimental=True, GoVersion=go1.8.3 Building test
compose.cli.verbose_proxy.proxy_callable: docker build <- (pull=False, cache_from=None, stream=True, nocache=False, labels=None, tag=u'tdmcv1_td', buildargs={}, forcerm=False, rm=True, path=u'C:\\test\\v1', dockerfile='Dockerfile')
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose\cli\", line 68, in main
File "compose\cli\", line 118, in perform_command
File "compose\cli\", line 239, in build
File "compose\", line 314, in build
File "compose\", line 888, in build
File "compose\cli\", line 55, in proxy_callable
File "site-packages\docker\api\", line 141, in build
File "site-packages\docker\utils\", line 14, in tar
File "site-packages\docker\utils\", line 100, in create_archive
File "", line 1881, in gettarinfo
WindowsError: [Error 3] The system cannot find the path specified: u'C:\\test\\v1\\some-massive-path\\node_modules\\recursive-node_modules\\node_modules\\more-recursive-node_modules\\node_modules\\seriously-how-long-do-some-of-these-old-npm-nests-go\\node_modules\\finally-a-package\\package.json'
Failed to execute script docker-compose

This is looking to bundle up a node_modules folder, ignore them from the build like so:

$> cat .dockerignore

Still hanging?

If it still lags, then chances are you’ve got large files in your repo, check the size of the dir by:

$> du -hc | grep total
3.6G total

To find those pesky files:

$> find ./ -xdev -type f -size +50M -exec ls -alh {} \;
-rw-r--r-- 1 mre 1049089 1000M Aug 29 11:16 ./file.txt
-rw-r--r-- 1 mre 1049089 1000M Aug 29 11:16 ./file1.txt
-rw-r--r-- 1 mre 1049089 1000M Aug 29 11:16 ./file2.txt

If that comes back with anything then you should probably put those files/dirs in your .dockerignore file.


I quickly created the dummy files by running:

dd if=/dev/urandom of=file1.txt bs=1048576 count=1000

a few times with different filenames to generate massive text files with gobble-di-gook contents.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.