8 of 10: More Docker Containers.

Or: Same Again, but Differently Done.

8 of 10: More Docker Containers.

Homelab | LXD Manager | Docker | Docker Desktop | Deno | MariaDB | Portainer | More Docker | Docker Swarm | CrowdSec


I will create, and configure, another container for Docker. I will call it 'docker2', and I will enable nesting within the container. I will then install Docker, change the Docker IP address, test the installation, and change my settings (if needed).

An Introduction.

In a previous post, I installed Docker in a LinuX Container. This time, I will... install Docker in a Linux container. However, I'll be using a modified, and simplified, process to achieve this outcome.

The purpose of this post is to formalise a process for installing Docker in Linux containers.

The Big Picture.

My next post is all about installing, and setting up, a Docker Swarm solution. A prerequisite for running a Docker Swarm is to have at least 3 Docker servers.

Beyond experimenting with Docker Swarm, I will also reference this post while learning to build infrastructure as code (IaC) solutions. I will need to practice making state files (For TerraForm) and Playbooks (for Ansible), so deploying Docker containers seems like a good candidate for learning IaC automation.

Installing Docker in a Container. Again.

  • From the homelab terminal (CTRL + ALT + T), I create a new container called 'docker2' where I set nesting to true:
lxc launch ubuntu:22.04 docker2 -c security.nesting=true

NOTE: Nesting allows the 'docker2' container to host another container system, e.g. Docker.

  • I bash into the new container:
lxc exec docker2 -- bash
  • I update and upgrade the 'docker2' container:
sudo apt clean && sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove -y
  • I install Docker:
sudo apt install -y docker.io

NOTE: For the sake of brevity, I have skipped:

Changing the Docker IP Address.

  • I open (or create) a file in Nano:
sudo nano /etc/docker/daemon.json
  • I add the following object, save the changes, and exit Nano:
    "bip": ""
  • I restart Docker:
sudo service docker restart

Testing the Docker Installation.

  • I run the 'hello-world' Docker project:
sudo docker run hello-world

Other Docker Settings.

  • If the 'hello-world' test fails, I will need to exit the container:
  • I configure the docker socket for the 'docker2' container:
lxc config device add docker2 docker-dev unix-char path=/var/run/docker.sock
  • I bash back into the 'docker2' container:
lxc exec docker2 -- bash
  • I run the 'hell-world' project again:
sudo docker run hello-world

The Results.

This post provides a step-by-step guide on creating and configuring a new Docker container called 'docker2', enabling nesting, installing Docker, changing the Docker IP address, and testing the installation. By following these instructions, I can easily set up, and manage, Docker in a LinuX Container.

In Conclusion.

Spinning up, and tearing down, Docker containers may seem whimsical, but the ephemeral nature of containers is an important part of my homelab experience. I'm working my way toward an integrated solution for the 12 Startups project. The more posts I publish, the closer I get to the Agile-DevSecOps-CI/CD Nirvana.

Until next time: Be safe, be kind, be awesome.

Homelab | LXD Manager | Docker | Docker Desktop | Deno | MariaDB | Portainer | More Docker | Docker Swarm | CrowdSec