Docker VPS guide
Run Docker on a VPS.
Step by step.
Docker runs apps in containers, so you can start a database, a website, a bot or a self-hosted tool with one command and move it between servers easily. This guide installs Docker and Docker Compose on your own HostingBaba Linux VPS.
What you need
A Linux VPS with Ubuntu 24.04 LTS (choose it on the order form) and SSH access from your own computer. Our smallest VPS plan has 4 vCPU and 8 GB of memory. Check what your apps need and watch memory use with docker stats; if your apps wait on the disk, the NVMe guide helps you decide whether an NVMe plan is worth it.
Step 1: install Docker
Log in to the server over SSH as root with the details from your dashboard. Update it, then install Docker and the Compose plugin from Docker's own package repository, as Docker's guide for Ubuntu describes:
apt update && apt -y upgrade
apt install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/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/ubuntu $(. /etc/os-release && echo "$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 it works:
docker run --rm hello-world
Step 2: start an app with Compose
Each app gets a folder with a compose.yaml file that describes its containers. This example runs a small web server that answers only on the server itself (127.0.0.1), which is the safe default:
mkdir -p /opt/web && cd /opt/web
nano compose.yaml
services:
web:
image: nginx:stable
restart: unless-stopped
ports:
- "127.0.0.1:8080:80"
docker compose up -d
curl http://127.0.0.1:8080
restart: unless-stopped brings the container back after a reboot. To see logs, run docker compose logs -f in the app's folder.
Step 3: firewall
Turn on the firewall for SSH. If you use a different SSH port, allow that one instead of OpenSSH. Ports published by Docker bypass this firewall, so publish a port to the internet only when you mean to: write \"80:80\" to make it public, or \"127.0.0.1:8080:80\" to keep it on the server.
ufw allow OpenSSH
ufw enable
Step 4: updates and backups
To update an app, read its release notes, make a backup, then pull the new image and restart:
cd /opt/web
docker compose pull && docker compose up -d
Your data lives in Docker volumes or in folders you mount. Use each app's own backup or export procedure, or stop the app before copying its data, so databases are not copied half-written. Store backups off the server, for example with scp or rsync, and test that you can restore them. We do not back up your server by default.
What is not allowed
Everything your containers do must follow our Acceptable Use Policy: no spam, phishing, malware, attacks, scanning systems you are not allowed to test, or Tor exit nodes.