LXD Storage Pools

In LXD, by default you are provided a storage pool named “default”. The default storage pool is where all LXD containers store their data. When you do a “lxd init” to configure a LXD server, I have mentioned in the past that having a default storage pool formatted as a zfs pool provides a lot of efficiency as well as data protection.

Recently, I tried to move my LXD container with my Discourse forum over to another LXD server. My Discourse was originally hosted on a QNAP NAS and LXD on the QNAP has a “dir” storage pool instead of zfs.

I made a backup of the existing container with:

lxc export Discourse Discourse-Test.tar.gz

When I imported the container to the new system, I discovered that docker was not running correctly.


After much research, I discovered that my original discourse container on the QNAP was running in a default storage pool of type “dir” and my new LXD target server had a default pool of type “zfs”.

The discourse application had created a “docker” storage volume of type “overlay2”. As it turns out, the overlay2 file system in docker cannot be hosted on a zfs storage pool and this is documented on the Linux Containers site.

Normally, docker containers can be nested inside of LXD in a zfs storage pool just fine. The gotcha was that the Discourse docker container had internally created an overlay2 volume.

I corrected this by creating a directory “dir” storage pool on the new system.

lxc storage create dirpool dir

Then I moved the discourse container from the default zfs pool where it was imported, over to the new directory storage pool and renamed the container to its original name.

lxc stop Discourse-Test
lxc move Discourse-Test   Discourse-Temp -s dirpool
lxc move Discourse-Temp Discourse-Test
lxc start Discourse-Test

At this point, the nested docker daemon was running correctly and the overlay2 volume in the nested Docker was working perfectly.

The command to list your storage pools.

lxc storage list

The command to list which containers are using a particular storage pool (for a pool named “dirpool”)

lxc storage show dirpool

In order to delete a storage pool, it must have no containers using it. The list command can be used to see if a storage pool has “0” containers using it.

lxc storage list

To delete an unused storage pool named “dirpool” if it has zero containers using it.

lxc storage delete dirpool