Docker runs applications in containers that carry everything they need with them. Docker Compose describes a whole application (for example a website, a database and a cache) in one file and starts it with one command. Most tutorials on running your own applications build on it, for example n8n, Nextcloud or Uptime Kuma.
For maximum stability, we recommend installing it on a Hukot.net VPS: your server is ready within 60 seconds of ordering and your data stays in a data centre in the Czech Republic.
Prerequisites #
- A VPS with 64-bit Ubuntu 22.04 / 24.04 / 26.04 LTS or Debian 12 / 13.
- SSH access as a user with
sudorights. You can create the user by following Adding and removing users in Linux and set up key-based login with SSH with public-key authentication. - Docker itself runs on the smallest tariff; memory and disk are used by the applications. When they need more, you can switch to a higher tariff right in the administration and pay only the difference.
Install Docker from Docker's official repository, not the docker.io package from your distribution. The repository always has current versions, including the Docker Compose plugin.
Installation #
Removing old packages
If the server already has Docker from the distribution or Podman, remove them so they don't conflict with the official packages:
sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc | cut -f1)
sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-doc docker-buildx podman-docker containerd runc | cut -f1)
On a clean server the command reports that none of the packages are installed. That's fine.
Docker repository
Add Docker's signing key and repository:
sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt update
sudo apt install -y 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
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
Docker Engine and Docker Compose
Install Docker Engine, the Docker Compose plugin and the other tools:
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
The docker service starts right after the installation and on every boot.
The get.docker.com script installs Docker with one command, but Docker doesn't recommend it for production servers: a later run can unexpectedly upgrade to a new major version.
Verification #
-
Check that the service is running. The output should say
active (running):sudo systemctl status docker -
Run a test container. It downloads a small image, prints
Hello from Docker!and exits:sudo docker run hello-world -
Check the Docker Compose version:
docker compose version
Docker Compose is run as docker compose, with a space. The old standalone docker-compose with a hyphen is no longer developed and you don't need it.
Docker without sudo #
To let your user run Docker without sudo, add it to the docker group. The change applies from your next login:
sudo usermod -aG docker $USER
After logging in again, check that the command works without sudo:
docker run hello-world
Membership in the docker group equals root access: through a container, any file on the server can be read and changed. Add only users you would also trust with sudo, never the user an application or AI agent runs as.
Docker and the firewall #
A port published by a container (ports in Compose or -p with docker run) is opened by Docker directly in the kernel rules. Traffic to the container passes before the UFW rules apply, so the firewall doesn't block it. A port published as 8080:80 is reachable from the whole internet even if you never allowed it in UFW.
That's why you should publish application ports only on 127.0.0.1:
ports:
- "127.0.0.1:8080:80"
The application is then reachable only from the server itself. Expose it through Nginx as a reverse proxy with an HTTPS certificate by following Nginx as a reverse proxy, or connect to it through an SSH tunnel. Keep only SSH, HTTP and HTTPS open on the firewall; see Setting up a firewall with UFW.
Your first Docker Compose application #
Try Compose with the Nginx web server.
-
Create a directory for the application and a
compose.yamlfile in it:mkdir -p ~/hello-compose cd ~/hello-compose nano compose.yaml -
Paste into the file:
services: web: image: nginx:alpine ports: - "127.0.0.1:8080:80" restart: unless-stoppedrestart: unless-stoppedmeans the container starts again after a crash or a server reboot, until you stop it yourself. -
Start the application in the background and look at its status:
docker compose up -d docker compose ps -
Check that Nginx responds and the port listens only locally. The
ssoutput should show127.0.0.1:8080:curl -I http://127.0.0.1:8080 sudo ss -tlnp | grep 8080 -
Stop and remove the test application:
docker compose down
Follow the application's logs with docker compose logs -f; update it to newer images with docker compose pull followed by docker compose up -d.
Limiting log size #
By default, Docker keeps container logs without any limit, and on a smaller disk they can fill it up. Set up log rotation in /etc/docker/daemon.json:
sudo nano /etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
Each container's logs then take at most 30 MB. Restart Docker:
sudo systemctl restart docker
The setting applies only to newly created containers. Recreate running Compose applications with docker compose up -d --force-recreate.
Updates #
Docker from the official repository is updated together with the system:
sudo apt update
sudo apt upgrade
Docker restarts during the update. Containers with restart: unless-stopped start again on their own.
Before a bigger update, create a snapshot in the Hukot.net VPS administration. If anything breaks after the update, you can roll the server back to its previous state.
To clean up containers and images you no longer need, see How to stop all Docker containers and How to remove all Docker containers and images.
Why choose our VPS? #
Unlike public clouds, we guarantee that your data stays in the Czech Republic, with top-class connectivity. Docker on a Hukot.net VPS is the foundation for running your own applications instead of paid cloud services, with your data under your control.
Want to run your own applications? #
Order a VPS from Hukot.net and start your first container on it today.