General

Docker on a VPS: Run Containers Without the Cloud Bill

Aziz ur Rehman 14 September 2026

Docker on a VPS lets you package an application and everything it needs into a container, then run it on hardware you control for a fixed monthly price. You skip the usage-based bills and limited customization of many managed container platforms while keeping the same portable workflow developers already use.

What Docker Is (One Clear Paragraph)

Docker is an open platform for developing, shipping, and running applications. It packages your code, runtime, system tools, libraries and settings into a lightweight, standalone unit called a container. Containers share the host operating system kernel instead of needing a full guest OS the way virtual machines do, so they start fast and use fewer resources. You get isolation and consistent behaviour from your laptop to a server. Official Docker documentation describes it as the way to separate applications from infrastructure so you can deliver software more quickly.

That is the core idea. Everything that follows is practical: install it on an Ubuntu VPS, run a first container, define a small multi-service side project with Docker Compose, and apply resource limits so one container cannot starve the rest of the machine.

Install Docker Engine on Ubuntu VPS

You need a 64-bit Ubuntu LTS release (22.04, 24.04 or 26.04) with root or sudo access. The steps below follow the official Docker Engine installation method using the apt repository.

First remove any conflicting packages that some Ubuntu images ship by default:

sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc 2>/dev/null | cut -f1) 2>/dev/null || true

Add Docker’s official GPG key and repository:

sudo apt update
sudo apt install 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

Install the packages:

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

Start and enable the service, then verify:

sudo systemctl enable --now docker
sudo docker run hello-world

You should see a confirmation message that the test image pulled and ran successfully. Add your user to the docker group if you want to drop the sudo prefix for everyday commands (log out and back in afterwards):

sudo usermod -aG docker $USER

Docker is now ready on your VPS.

Run Your First Container

The hello-world image already proved the install works. For a more useful test, pull and run a lightweight web server:

docker run -d -p 8080:80 --name webtest nginx:alpine

Open http://YOUR_VPS_IP:8080 in a browser. You should see the default Nginx page. Stop and remove it when finished:

docker stop webtest
docker rm webtest

This pattern (image → container → port mapping) is the foundation for almost every Docker workflow.

Docker Compose for a Side Project

Most real side projects need more than one process: an application, a database, sometimes a reverse proxy or cache. Docker Compose lets you declare the whole stack in a single YAML file and start or stop it with one command.

Create a project directory and a docker-compose.yml. Here is a minimal example that runs a simple web app plus PostgreSQL (adjust the image and environment variables for your actual stack):

services:
  web:
    image: your-app-image:latest   # or build: .
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=postgres://app:secret@db:5432/appdb
    depends_on:
      - db
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: "1.0"
          memory: 512M
        reservations:
          memory: 256M

  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: appdb
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: "1.0"
          memory: 1G
        reservations:
          memory: 512M

volumes:
  pgdata:

Bring the stack up:

docker compose up -d

Check status and logs:

docker compose ps
docker compose logs -f

Stop everything cleanly:

docker compose down

You now have a repeatable side-project environment that travels with the compose file. Change the code, rebuild the image if needed, and re-run the same two commands.

Resource Tips: RAM and CPU Limits

On a VPS the total RAM and CPU are fixed. Without limits a single container can consume everything and force the kernel to OOM-kill processes, sometimes including SSH. Docker (and Compose) let you set hard limits and soft reservations.

In the compose example above the deploy.resources section already shows the pattern. For a classic docker run command you use flags:

docker run -d --memory=512m --cpus=1.0 --name myapp your-image

Practical budgeting rules that match common VPS sizes:

  • Leave roughly 1–1.5 GB for the host OS, Docker daemon, SSH and page cache on a typical 4–8 GB plan.
  • Sum of all container memory limits should stay under the remaining amount.
  • CPU limits are soft throttles (CFS quota); memory limits are hard and trigger OOM kill inside the container when exceeded.

(Illustrative allocation. Measure your own stack with docker stats before locking numbers in production.)

Start conservative, watch docker stats --no-stream under real load, then tighten or raise limits. This is one of the biggest practical advantages of running Docker on a VPS: you decide the ceilings instead of guessing how a managed platform will bill or throttle you.

Full Control and Predictable Price vs Managed Container Platforms

Managed platforms (Fargate-style, Cloud Run-style, Container Apps, etc.) remove some operational work. They also introduce usage-based pricing for CPU, memory, requests and egress that can rise quickly once a side project starts receiving traffic. Docker on a VPS keeps the monthly cost fixed for the hardware you rent. You control the exact images, the network rules, the volumes, the restart policy and the resource ceilings.

(Illustrative only. Actual managed-platform bills depend on region, free tiers and traffic patterns. Always check current vendor pricing.)

You also keep the freedom to run any combination of containers, add monitoring, tune kernel parameters or swap the underlying OS image when you need to. That combination of control plus a predictable bill is the practical reason many builders move side projects and early SaaS workloads onto a VPS once the prototype stage is over.

Why Rabisu for Docker Workloads

Rabisu VPS plans give you full root access, Docker-ready Ubuntu (or Debian) images, and transparent pricing that already includes daily backups and DDoS protection. You can size the plan to the actual RAM and CPU your containers need instead of paying for idle capacity or surprise egress. See current Linux VPS options at rabisu.com/vps (or the Linux-specific page). When you are ready to harden the host or document the full production checklist for a small SaaS, the related buyer and trust guidance lives in our how-to-choose-a-VPS article.

You get the same containers you already know how to build, running on hardware whose monthly price does not change with request volume.

Quick Answers

What is Docker in simple terms?

Docker packages an application and its dependencies into a portable container so the same unit runs the same way on your laptop and on a server.

Can I run Docker on any Ubuntu VPS?

Yes, provided the VPS is 64-bit and you have root or sudo access. Official support covers the current Ubuntu LTS releases. Follow the repository method above for the cleanest install.

Do I need Docker Compose for a single container?

No. Plain docker run is enough for one service. Compose becomes useful the moment you need two or more containers that talk to each other.

How do I stop one container from using all the RAM?

Set a memory limit with --memory (or the deploy.resources.limits.memory key in Compose). The container is then OOM-killed if it exceeds the limit instead of taking down the whole VPS.

Is Docker on a VPS cheaper than managed container platforms?

For always-on or steadily growing workloads the fixed monthly VPS price is often more predictable. Managed platforms can be cheaper for pure scale-to-zero or extremely spiky traffic, but the bill is no longer fixed. Measure both against your actual usage pattern.