The way to an own clowd (part 4) - The own shipping yard

Today we’re talking about another important instance for your own cloud: Container technology (for example, Docker).

Docker – or more generally containerization – is like a delivery service for software: It allows you to package important applications into small, self-contained bundles that run identically everywhere, no matter what system is underneath. This greatly simplifies the installation of services, as you don’t have to struggle through complex dependency lists each time.

Installing Docker

As always, you should first update your Debian package system:

sudo apt update && sudo apt upgrade -y

Before installing Docker, you need to install a few additional packages, as you will be adding new package sources:

sudo apt install -y ca-certificates curl gnupg lsb-release

This adds the required key for the Docker repository:

sudo install -m 0755 -d /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

sudo chmod a+r /etc/apt/keyrings/docker.gpg

Next, add the Docker repository as a new package source and update your package list:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update

Now you can install Docker:

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

Check if the Docker service is running with:

sudo systemctl status docker

If the service is not running, you can start it with

sudo systemctl start docker

To make working with Docker easier, you can add your current user to the Docker group. This will save you from having to use sudo with Docker commands:

sudo usermod -aG docker $USER

Note: After this change, you should log out and back in so that the group permissions become active.

To make your life with Docker even easier, it’s recommended to run your own Docker registry—a local container repository:

sudo mkdir -p /opt/registry/data

docker run -d \
  --restart=always \
  --name registry \
  -p 127.0.0.1:5000:5000 \
  -v /opt/registry/data:/var/lib/registry \
  registry:2

This instructs the Docker service to download and automatically start the registry image with version (or tag) 2.

You can test this by rebooting the server:

sudo reboot

and then running

curl -X GET http://localhost:5000/v2/_catalog

Usually, you will receive an empty list of stored repositories as JSON:

{"repositories":[]}

Quick & Dirty

# Update system and packages
sudo apt update && sudo apt upgrade -y
sudo apt install -y ca-certificates curl gnupg lsb-release

# Add Docker repo key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add Docker repository and update package list
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update

# Install Docker
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Add user to Docker group
sudo usermod -aG docker $USER

# Local Docker registry
sudo mkdir -p /opt/registry/data
docker run -d \
  --restart=always \
  --name registry \
  -p 127.0.0.1:5000:5000 \
  -v /opt/registry/data:/var/lib/registry \
  registry:2