Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why docker build is so slow

My docker is very slow when I'm trying to build images on my laptop. I tried to build same image at my ubuntu inside virtual machine with same docker version and it builds it in 5 seconds, but on my laptop it evaluates every statement like 30 times slower. Even ENV command!

Laptop uses OpenSUSE 42.2 Leap with Btrfs as root file system, HDD with 5400 rpm and also it's encrypted. I know all these factors but are they so significant that my build takes 15mins instead of 5sec?

Docker 1.13.1.

Thanks.

UPD.

not sure if it helps or not, but when I run docker build -t test . on my virtual machine, it uses 10% of my 4-core CPU for 5 secs and heavilly uses HDD.

however on laptop it uses one core of my 4-core CPU for 100% all the time and HDD remains idle almost all the time.

here is nmon statistics: enter image description here

like image 237
Elessar.perm Avatar asked Mar 02 '17 06:03

Elessar.perm


2 Answers

Not sure if this was the same problem but just made my build go from 5 minutes to 5 seconds, by adding the following .dockerignore file to the same directory as my docker-compose.yml file.

**/bin
**/obj
**/node_modules
.git
like image 99
JoelFan Avatar answered Sep 19 '22 08:09

JoelFan


This sounds like your laptops btrfs filesystem is having issues - as in its fragmented. Try looking into tuning btrfs. I would also look into this section of the docker documentation related to docker and btrfs https://docs.docker.com/engine/userguide/storagedriver/btrfs-driver - specifically the section on performance which points to fragmentation.

like image 41
abdollar Avatar answered Sep 21 '22 08:09

abdollar