What is it?
LXC is a small container running on the host. It offers less isolation compared to fill blown VM. I can spin up LXCs easily, so I wanted to figure out a which steps are required to create a Docker host.
Warning
Running Docker inside an LXC might be a source of potential security risks. A full blown VM would provide greater isolation, but it comes at a cost of higher virtualisation overhead.
How to do it
- Create a new LXC. I based it on Debian 12.
- Use following script to install Docker (run as root)
# Add Docker's official GPG key:
apt-get update
apt-get install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install docker-ce docker-compose-plugin
- Enable Docker service
systemctl enable --now docker
- Now, you can use Docker