Installing Docker and Docker Compose
Log in to the server as root and run the commands below. They add Docker's official repository (automatically detecting whether the system is Ubuntu or Debian) and install Docker Engine with the Compose plugin:
# apt update
# apt install -y ca-certificates curl
# install -m 0755 -d /etc/apt/keyrings
# . /etc/os-release
# curl -fsSL https://download.docker.com/linux/$ID/gpg -o /etc/apt/keyrings/docker.asc
# chmod a+r /etc/apt/keyrings/docker.asc
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/$ID $VERSION_CODENAME stable" > /etc/apt/sources.list.d/docker.list
# apt update
# apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Check that everything is installed by running the test container:# apt install -y ca-certificates curl
# install -m 0755 -d /etc/apt/keyrings
# . /etc/os-release
# curl -fsSL https://download.docker.com/linux/$ID/gpg -o /etc/apt/keyrings/docker.asc
# chmod a+r /etc/apt/keyrings/docker.asc
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/$ID $VERSION_CODENAME stable" > /etc/apt/sources.list.d/docker.list
# apt update
# apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# docker run --rm hello-world
# docker compose version
The message "Hello from Docker!" confirms Docker is working. The service is already running and starts automatically with the server.
# docker compose version
Running your first service with Docker Compose
Create a folder for the project and, inside it, a compose.yaml file. As an example, we will publish an Nginx web server on port 8080:
# mkdir -p /root/myproject && cd /root/myproject
# nano compose.yaml
Paste the content below and save the file:# nano compose.yaml
services:
web:
image: nginx:alpine
ports:
- "8080:80"
restart: unless-stopped
Now start the service in the background:web:
image: nginx:alpine
ports:
- "8080:80"
restart: unless-stopped
# docker compose up -d
Done: open http://SERVER-IP:8080 in your browser and you will see the Nginx welcome page. The server IP address is in your account panel.Everyday commands
Always from inside the project folder:- docker compose ps: lists the project containers and their state;
- docker compose logs -f: follows the logs in real time;
- docker compose pull && docker compose up -d: downloads the newest image versions and recreates the containers;
- docker compose down: stops and removes the containers (volumes with data are kept).
If you have any difficulties, open a support ticket: Open ticket