How do I build a profile that sets-up containers correctly to run docker?

I have read How to run Docker inside LXD containers, and would like to have a profile that I can use during lxc launch that applies the configuration changes, and uses the correct storage.

I created a storage volume like this:

lxc storage create docker btrfs
❯ lxc storage list
+---------------------+--------+-------------------------------------------+-------------+---------+---------+
|        NAME         | DRIVER |                  SOURCE                   | DESCRIPTION | USED BY |  STATE  |
+---------------------+--------+-------------------------------------------+-------------+---------+---------+
| default             | zfs    | rpool/lxd                                 |             | 5       | CREATED |
+---------------------+--------+-------------------------------------------+-------------+---------+---------+
| docker              | btrfs  | /var/snap/lxd/common/lxd/disks/docker.img |             | 2       | CREATED |
+---------------------+--------+-------------------------------------------+-------------+---------+---------+
| workstation-default | zfs    | barra500/Ubuntu-Workstation/lxd-storage   |             | 99      | CREATED |
+---------------------+--------+-------------------------------------------+-------------+---------+---------+

My workstation file-systems are zfs.

I created a profile docker after inspecting the config of the container created in the exercise. It looks like this:

---
config:
  security.nesting: "true"
  security.syscalls.intercept.mknod: "true"
  security.syscalls.intercept.setxattr: "true"
description: ""
devices: {}
name: docker
used_by: {}

I ran it on a command-line like this:

lxc launch images:ubuntu/jammy --profile default --profile docker --storage docker $c1

The problem may be in translating:

lxc config device add $c1 docker disk pool=docker source=$c1 path=/var/lib/docker

Into the form of a profile. I can’t personally parse that line. Here it is directly from the instructions:

lxc config device add demo docker disk pool=docker source=demo path=/var/lib/docker

The cli process hangs during the lxc launch.
I am stuck as this point…

Unless someone has a simple solution readily to hand - I will avoid docker in lxc containers.

Hello,

I had some success with the profiles present in this tutorial:

Take a look over at the differences between zfs/ext4 in the profiles there. There might be some hints in there for you.

1 Like

This video might help: