Enalbe docker in LXD5
lxd lxc docker ubuntuCreate LXD Container
NOTE: Docker will not run will with the default zfs
file system
- Create a new
btrfs
storage pool calleddocker
. The Btrfs is one of the storeage pools Docker support natively.
lxc storage create docker btrfs
- Create a new LXD instance and call it
demo
.
lxc launch images:ubuntu/22.04 demo
- Create a new storage volume on the
docker
storage pool.
lxc storage volume create docker docker-vol-demo
- Attach the volume to the
demo
container
lxc config device add demo docker disk pool=docker source=docker-vol-demo path=/var/lib/docker
# if you install docker with snap, the volume path should be /snap/docker. Use the one as below.
lxc config device add demo docker disk pool=docker source=docker-vol-demo path=/snap/docker
- Allow nested containers required for Docker
lxc config set demo security.nesting=true security.syscalls.intercept.mknod=true security.syscalls.intercept.setxattr=true
- Apply these chages by restarting the container.
lxc restart demo
Install and verfy docker.
Reference
Written on November 7, 2023