14

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/… Mar 2, 2017 at 6:44
  • yup, I have all my files inside build context and it's just a bunch of bash scripts Mar 2, 2017 at 6:53
  • so strace docker build maybe a big hammer, but should show what happens during your 15 minutes 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 Mar 2, 2017 at 10:39

2 Answers 2

14

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
1
  • 1
    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.
    – JayTheKay
    Feb 1 at 14:32
4

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.

7
  • 1
    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 ;)
    – Nanne
    Mar 2, 2017 at 7:48
  • thanks, that's correct. I should have said fragmented - updated it.
    – abdollar
    Mar 2, 2017 at 7:50
  • thanks for your answer, but I tried to defragment my fs and it didn't help Mar 2, 2017 at 10:09
  • 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.
    – abdollar
    Mar 2, 2017 at 17:28
  • 2
    you were right. it was btrfs problem. i just moved docker directory to XFS and now it works fine Mar 3, 2017 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.