Article
· Jun 9, 2018 2m read

One simple Docker trick to halve your image build time

Note: with support for Overlay storage driver for InterSystems IRIS containers this article is no longer relevant. The article is left here for archive purposes.

 

When starting with containers and docker it's important to remember to set correct storage driver value. InterSystems IRIS container supports devicemapper storage driver on Linux and it can be used in two modes:

  • loop-lvm
  • direct-lvm

The first and easy approach called loop-lvm is to edit docker configuration and add this line

{
  "storage-driver": "devicemapper"
}

That certainly seems simple. But both InterSystems documentation and Docker documentation state:

InterSystems:

be sure to read Docker’s explanation of using the devicemapper storage driver in direct-lvm mode for management of container images

Docker:

Production hosts using the devicemapper storage driver must use direct-lvm mode. This mode uses block devices to create the thin pool. This is faster than using loopback devices, uses system resources more efficiently, and block devices can grow as needed. However, more set-up is required than loop-lvm mode.

direct-lvm is certainly the recommended, if harder to configure approach. But how faster is it? That depends upon how much time you  spend reading/writing to the image, but I've been able to observe 2-3x speed-up time for a real-world application (not a test app, hundreds of classes, etc.). After moving from loop-lvm to direct-lvm the image build time and associated operations are now completed ~60% faster than before.

Discussion (2)0
Log in or sign up to continue

What do you mean? How does it look in config file?

In the best case like this:

{
  "storage-driver": "devicemapper",
  "storage-opts": [
    "dm.directlvm_device=/dev/xdf",
    "dm.thinp_percent=95",
    "dm.thinp_metapercent=1",
    "dm.thinp_autoextend_threshold=80",
    "dm.thinp_autoextend_percent=20",
    "dm.directlvm_device_force=false"
  ]
}

Docker documentation explains setting direct-lvm in detail.