Getting Started with Docker on a VPS

Written by the ApexVPS team • Last updated: July 2026 • 8 min read

Running Docker on a VPS is the fastest way to go from an empty Ubuntu box to a running web app, database, or self-hosted service in minutes. Instead of wrestling with system packages and conflicting dependencies, you pull a pre-built image and start a container. This beginner guide walks you through installing Docker and Docker Compose on Ubuntu or Debian, the core concepts you need, launching your first container, persisting data with volumes, and a few security basics so you do not get burned.

Why run Docker on a VPS?

A virtual private server gives you full root access and dedicated resources, which is exactly what containers want. With Docker installed you can run many isolated services side by side without them stepping on each other. Each container ships with its own libraries, so a Node app, a Postgres database, and a reverse proxy can coexist on one machine cleanly. If your goal is self-hosting apps on a VPS — think a personal cloud, a wiki, or a media server — Docker keeps every service tidy and reproducible.

Containers are also portable. The same Compose file that runs on your laptop runs on the server, which removes the classic "works on my machine" problem. Rebuilding a service after a mistake takes seconds rather than an afternoon of reinstalling packages.

Core concepts in plain English

Before touching the command line, it helps to know four building blocks:

Step 1: Install Docker on Ubuntu or Debian

The simplest, officially supported way to install Docker Engine is the convenience script. Connect to your server over SSH and run:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

This installs Docker Engine along with the Compose plugin. When it finishes, confirm the versions:

docker --version
docker compose version

By default Docker requires sudo. To run it as your normal user, add yourself to the docker group, then log out and back in so the change takes effect:

sudo usermod -aG docker $USER

Docker also starts on boot on most systems. If you ever need to enable it manually:

sudo systemctl enable --now docker

Prefer the package-repository method or want the full details for your exact distribution? The official Docker installation documentation covers every option. The convenience script above is ideal for a fresh VPS.

Step 2: Run your first container

Test the install with the classic hello-world image:

docker run hello-world

Docker pulls the image, runs it once, and prints a confirmation message. Now let us run something you can actually see. This command starts an Nginx web server in the background and maps port 8080 on the host to port 80 in the container:

docker run -d -p 8080:80 --name web nginx

Open http://your-server-ip:8080 in a browser and you should see the Nginx welcome page. A few flags worth knowing:

Check what is running, then stop and remove the container when you are done:

docker ps
docker stop web
docker rm web

A handful of commands cover most day-to-day work. docker images lists the images you have pulled, docker logs web shows a container's output for troubleshooting, and docker exec -it web bash opens a shell inside a running container so you can poke around. Learning these five or six commands is enough to manage a small server confidently, and you can look up the rest as you need them.

Step 3: Use Docker Compose for multi-container apps

Typing long docker run commands gets old fast. Docker Compose lets you describe your whole stack in a single file and bring it up with one command. Create a file called compose.yaml:

services:
  web:
    image: nginx:latest
    ports:
      - "8080:80"
    volumes:
      - web-data:/usr/share/nginx/html
    restart: unless-stopped

volumes:
  web-data:

From the same directory, start everything in the background:

docker compose up -d

Compose creates the network, the named volume, and the container for you. Useful companions:

docker compose ps
docker compose logs -f
docker compose down

The restart: unless-stopped policy means the service comes back automatically after a reboot or a crash — handy for a server you are not watching around the clock.

Step 4: Persist data with volumes

This is the part beginners most often get wrong. Anything written inside a container's own filesystem disappears when that container is removed or recreated. To keep data, put it in a volume. There are two common approaches:

Inspect and manage volumes from the command line:

docker volume ls
docker volume inspect web-data

As long as your important paths point at a volume, you can delete and rebuild containers all day without losing a byte. Back the volume directory up as part of your server backups.

Step 5: Update images and containers

Container images receive security and feature updates just like any software. Updating a Compose stack is a two-step routine: pull the newer images, then recreate the containers.

docker compose pull
docker compose up -d

Because your data lives in volumes, recreation is safe. Over time, unused images pile up and eat disk space. Clean them out occasionally:

docker image prune

Pin to specific version tags (for example postgres:16 instead of latest) when you want predictable, repeatable updates rather than surprises.

Basic Docker security for beginners

Containers are convenient, but they are not a magic security boundary. A few habits keep you out of trouble:

Before you expose anything publicly, work through our companion checklist on how to secure your VPS in the first 10 minutes — it covers SSH keys, a firewall, and automatic updates that pair perfectly with a Docker host.

Choosing a VPS that is ready for Docker

Docker runs on modest hardware, but dedicated resources make a real difference once you stack several containers. Shared, oversold hosting means a noisy neighbour can throttle your database at the worst moment. ApexVPS gives you truly dedicated vCPU, NVMe SSD storage, and full root access, so your containers get the performance you paid for. Every plan supports Ubuntu, Debian, and other popular distributions, and you can drop in your SSH key at signup.

Checkout is crypto-only through OxaPay, accepting Bitcoin, Ethereum, USDT and 30+ cryptocurrencies — no credit card, no bank account, and no KYC. You provide an email to receive access details, and that is it. Compare the specs and regions on the ApexVPS pricing page to find a plan sized for your container workload.

Frequently asked questions

Do I need a lot of RAM to run Docker on a VPS?

No. Docker itself is lightweight and adds little overhead. One or two containers run comfortably on 2 GB of RAM, while 4 GB or more gives headroom for databases and several services at once.

Is it docker-compose or docker compose?

On a modern install, Compose ships as a plugin, so the command is docker compose with a space. The older standalone docker-compose binary still works but is being phased out — use the plugin version on a fresh setup.

Where is my data stored when a container is deleted?

Anything written inside the container is lost on removal. Store important data in a named volume or bind mount so it survives container recreation. That is how databases and uploads stay safe.

Can I pay for a Docker-ready VPS with cryptocurrency?

Yes. ApexVPS checkout is crypto-only via OxaPay and accepts Bitcoin, Ethereum, USDT and 30+ coins. Signup needs only an email, with no credit card and no identity verification.

Ready to spin up your first container? See Docker-ready VPS plans →