docker build is very slow even with simple commands
Another consideration that was not mentioned here, is that on armv7, most packages that you may want to install with pip or apt-get, are not packaged as binaries.
That means that on an amd64 architecture, pip install downloads a binary and it just merely copies it in the right place, but on armv7, it won't find a suitable binary and will instead downloads the source code and will need to build it from scratch.
When you have a package with lots of dependencies, and they need to be built from source, it takes a looong time.
You can check on what is going on during docker build using the -v
flag on pip
pip install -v -r requirements.txt
Each instruction of the Dockerfile
will be run in a container. What it means is that for each instruction it will do the following :
- Instantiate a container from the image created by the previous step, which will create a new layer (the R/W one)
- Do the thing (pip install, etc..)
- Commit, which will copy the top layer as an image layer (I'm pretty sure it is copying the layer)
- And removing the container (if the
--rm
option is specified) (thus, removing the container Read/Write layer)
There are a few I/O operations involved. On an SSD it's really quick, as well as on a good hard drive. When you build it on the Raspberry PI, if you build it on the SD Card (or MicroSD), the performance of the SD card is probably not that good. It will depend on the class of you MicroSD and even then, I don't think it's really good for the card. I made the try with a simple node project, and it definitely took a few minutes instead of a few seconds like it did on my laptop. It is hardware related (mostly I/O for the SD Card, maybe a little bit the CPU, but...).
You might wanna try to use an external hard drive connected to the raspberry Pi and move the docker folders there, to see if the performance are better.
This is an old question but for reference, you may have been suffering from the chosen storage driver.
On Ubuntu/Debian, Docker uses by default an AUFS storage driver, which is quite fast. On other distributions, Docker uses by default a devicemapper storage driver, which is very slow with the default configuration (due to a "loop-lvm" mode, configured by default, and not recommandent for production use).
Check this guide for reference and to see how to configure the devicemapper storage driver in production (without loop mode) : https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/