Docker build lag

DynamicMonkeys
Aug 29, 2017 · 2 min read

If

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.

Try:

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
compose.service.build: 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\main.py", line 68, in main
File "compose\cli\main.py", line 118, in perform_command
File "compose\cli\main.py", line 239, in build
File "compose\project.py", line 314, in build
File "compose\service.py", line 888, in build
File "compose\cli\verbose_proxy.py", line 55, in proxy_callable
File "site-packages\docker\api\build.py", line 141, in build
File "site-packages\docker\utils\build.py", line 14, in tar
File "site-packages\docker\utils\utils.py", line 100, in create_archive
File "tarfile.py", 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
.git
**/node_modules
**/bower_components

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.

FYI:

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.

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade