Slow docker execution inside lxd container


I did a test, inside lxd container ubuntu 16.04, installed, then do following:

docker pull node:boron
time docker run node:boron echo ‘hello’

got :
real 1m13.067s
user 0m0.020s
sys 0m0.088s

I repeated the same procedure in the host running ubuntu 16.04, and got:

0.02user 0.00system 0:00.48elapsed 5%CPU (0avgtext+0avgdata 18908maxresident)k
0inputs+0outputs (0major+1389minor)pagefaults 0swaps

It is so slow inside the container to run a docker app, more than 1 minute while the same docker app runs in the host takes only 0.02 seconds, is this same to other docker images?


I got

real	0m14.721s
user	0m0.012s
sys	0m0.000s

(with SSD disk).

If you try, however, helloworld, you get

real	0m0.447s
user	0m0.008s
sys	0m0.012s

I assume that the issue here is that it takes time to read the files and launch node:boron. It’s about 1GB of files?
You can try some other benchmark (like with ab that makes many HTTP requests) to see how well node:boron responds after it has been launched.

The main source of the problem appears to be the choice of the storage driver for Docker, when it runs inside an LXD container. With docker info, we get

Storage Driver: vfs

Note: I am using docker-ce per

You are right, the issue is the storage, hello-world is so small, running it inside container or in the host has almost the same time elapsed, question now is, how to instruct the docker to use a faster storage driver? I believe apps packaged with docker usually has more than 100MB in size:

node boron e8c6ec267732 9 days ago 662 MB
hello-world latest 725dcfab7d63 2 weeks ago 1.84 kB

A workaround is to get LXD to use the btrfs storage backend, as described at
Then, Docker-in-LXD will be able to use as well btrfs for its storage driver.

An LXD storage backend of ZFS makes docker to use the vfs Docker storage driver, which is not optimal.

1 Like