Learning Docker or running one lightweight stateless container.
Ubuntu VPS foundation
How to Install Docker on Ubuntu VPS
Install Docker Engine from the official repository, verify Compose and run a safe test container.
Docker is the common foundation for many self-hosted VPS applications. The reliable path on Ubuntu is to use Docker's official apt repository, install Engine and the Compose plugin together, then verify networking and persistence before deploying an application. Avoid copying a random install script onto a production VPS when you need predictable updates.
Docker lets one VPS run several applications with repeatable configuration, isolated dependencies and a simpler migration path. It is useful for n8n, Open WebUI, dashboards, databases and small web stacks. It does not remove server administration: you still own the firewall, image updates, storage, backups and the blast radius of anyone who can access the Docker socket.
Where Docker earns its keep on a VPS
Move a Compose stack between VPS providers without rebuilding the server by hand.
Pull, recreate and roll back one service without replacing the whole VPS.
Separate application dependencies while keeping ports and persistent data explicit.
VPS requirements
Buy for the workload, not the install command
An application, database, reverse proxy and enough headroom for updates.
Several stacks, local image builds, search services or high log and database I/O.
Install path with checkpoints
Remove conflicting packages
Ubuntu may contain older packages with similar names. Removing only conflicting packages does not remove your future Docker data.
sudo apt remove -y docker.io docker-compose docker-doc podman-docker containerd runc || true
sudo apt update
sudo apt install -y ca-certificates curlAdd Docker's repository
Use the official keyring and repository for your Ubuntu release, then install the maintained packages.
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
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" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt updateInstall Engine and Compose
The Compose plugin is now invoked as docker compose, with a space, rather than the older docker-compose binary.
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
sudo docker run hello-world
docker compose versionDecide how to run Docker
Adding a user to the docker group removes sudo but grants root-equivalent control through the Docker socket. On a shared administrative server, keep using sudo or use rootless Docker instead.
sudo usermod -aG docker $USER
newgrp docker
docker run hello-worldA Docker group decision is a security decision
Adding a user to the docker group is convenient, but access to the Docker socket is effectively root-equivalent. On a personal VPS that trade-off may be reasonable. On a shared administrative machine, keep using sudo or investigate rootless Docker instead.
Do not expose the Docker daemon API to the public internet. Publish application ports intentionally and bind internal smoke tests to 127.0.0.1.
Finish with a disposable smoke test
Create a small Compose smoke test
A disposable test confirms port publishing and container lifecycle before you put a real application on the machine.
mkdir -p ~/docker-test && cd ~/docker-test
printf 'services:
web:
image: nginx:alpine
ports:
- 127.0.0.1:8080:80
' > compose.yml
docker compose up -d
curl -I http://127.0.0.1:8080
docker compose downCommon mistakes that cause real downtime
- Installing docker.io and docker-ce together, then troubleshooting mismatched packages
- Adding every administrator to the docker group without treating it as root-level access
- Publishing databases or admin ports on 0.0.0.0 when only a private network needs them
- Keeping application data only inside a container writable layer
- Choosing a tiny disk without allowing space for images, build cache, logs and database growth
Before deploying the first app
Next step
Keep the deployment moving
Sources and further reading
- Docker: install Engine on Ubuntu
- Docker: install the Compose plugin
- Docker: Linux post-installation and security note
- Ubuntu: containers for system administrators
Commands assume a fresh Ubuntu server. Replace domains, users, database names and provider-specific values before running them. VPS sizing is a practical starting point, not a guarantee: monitor the real workload and resize when CPU, memory, disk or network headroom becomes tight.