18

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

4
  • 1
    do you have your Dockerfile and all your needed files in a specific directory? If not the "buid context" is all your files of your current directory, and that will be slow. See stackoverflow.com/questions/26600769/… Commented Mar 2, 2017 at 6:44
  • yup, I have all my files inside build context and it's just a bunch of bash scripts Commented Mar 2, 2017 at 6:53
  • so strace docker build maybe a big hammer, but should show what happens during your 15 minutes Commented Mar 2, 2017 at 7:40
  • 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: i.imgur.com/EHAkQ78.jpg Commented Mar 2, 2017 at 10:39

2 Answers 2

18

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 
Sign up to request clarification or add additional context in comments.

3 Comments

Just one addition: The .dockerignore file needs to be in the docker compose context root directory, which can be different from the docker-compose.yml file location.
In my case, top revealed that more than 100% of a CPU was used by scand. An appropriate .gitignore helped.
this is what I was looking for. nice
7

This sounds like your laptops btrfs filesystem is having issues - as in it's fragmented. Try looking into tuning btrfs. I would also look into this section of the docker documentation related to docker and btrfs - specifically the section on performance which points to fragmentation.

7 Comments

I assume you mean it might be currently fragmented, en needs to be defragmented? Not that I know much about btrfs, so it's mostly from a linguistic point of view ;)
thanks, that's correct. I should have said fragmented - updated it.
thanks for your answer, but I tried to defragment my fs and it didn't help
I would try to upgrade docker and follow the instructions in the link above that mentions how you should configure docker with btrfs. This still sounds like a btrfs and docker issue.
you were right. it was btrfs problem. i just moved docker directory to XFS and now it works fine
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.