Install Docker on LXD

Vitor Gomes
3 min readJun 25, 2021

Step 1 — Create a profile to Docker

You don’t need to, however, if you want you can create a profile for your container or VM.

lxc profile create Docker
lxc profile list
lxc profile edit Docker

You can apply all configuration keys listed in LXD documentation — Instance keys.

config:
limits.cpu: “4”
limits.memory: 4GB
limits.memory.swap: “false”
linux.kernel_modules: ip_tables,ip6_tables,nf_nat,overlay,br_netfilter
raw.lxc: “lxc.apparmor.profile=unconfined\nlxc.cap.drop= \nlxc.cgroup.devices.allow=a\nlxc.mount.auto=proc:rw
sys:rw”
security.nesting: “true”
security.privileged: “true”
description: LXD profile for Docker
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
name: Docker
used_by:
- /1.0/instances/Main-Docker

Step 2— Create LXC container Ubuntu 21.04

If you created a profile you can use it when you create your container or VM.

lxc launch ubuntu:21.04 Main-Docker --profile Docker

Step 3 — Install Docker Engine

Using LXD, you can launch containers and get a shell into them using the following lxc command. This command uses the exec subcommand to run a process in the container mycontainer, and the full line of the process is whatever appears after space, in this case, bash.

lxc exec Main-Docker bash

The link below is a quickie install of Docker, the link is identified your platform, and then it does all the necessary installations and configurations.

curl -fsSL https://get.docker.com |bash

Then if you want to test to check if everything is working how about running the hello-world image

docker container run -ti hello-world

--

--