Container virtualization with Docker and Docker compose for your Homelab -simple and fast

Container virtualization with Docker and Docker compose for your Homelab -simple and fast
Docker and Docker compose

The advantages of virtual servers are now widely known. Container virtualizations of individual applications are somewhat newer. Wikipedia describes it in more detail.

Briefly summarized: Where I used to have to install and set up an Apache web server, PHP, an SQL database, my own certificates and more by hand, which took several hours, with container virtualization I can start everything with almost one command. Updating or moving containers to other host systems is also implemented very quickly. Overall, handling and dealing with containers in day-to-day operations is much easier than installing and configuring all components individually.

Docker serves as the basis for creating and managing containers in the first place. Docker compose serves as multi-container management. In the above example of a LAMP stack, you need an Apache web server container, an SQL container and so on. I can easily write down these individual containers in a single file with compose. Super easy!

In this post you will only find the installation of Docker and Docker compose. You can find individual Docker compose recipes in various posts on this blog. It is important to set up a reverse proxy. This ensures that all containers are accessible on the web under different domains with nice Lets Encrypt certificates. I will show you how to set this up in following posts.

Install Docker and Docker compose

Enough talking, here is the installation of Docker and Docker compose under Debian (other distributions). Just copy it in your terminal:

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo 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" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

And finaly install everything:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

You can test everything with the two commands:

docker -v
docker compose version

Now only individual services and containers are missing. It is best to set up a reverse proxy at the beginning so that everything can be reached nicely and cleanly with HTTPS later on. So take a look at the other instructions on the blog.