How to install Docker on a VPS, step by step
The foundation for everything else you self-host. Five commands, one check, and the permissions error that catches everyone the first time.
Short answer
Connect to the VPS over SSH, run the official get.docker.com script, add your user to the docker group, log out and log back in. Running docker run hello-world confirms it worked. It takes under ten minutes on a clean Ubuntu.
- Last updated
- June 10, 2026
- Last verified
- June 10, 2026
- Tested with
- Docker Engine 27.x sobre Ubuntu 24.04 LTS
Antes de empezar necesitas
- A VPS with Ubuntu 22.04 or 24.04 and root access
- An SSH client (Terminal on macOS or Linux, or PowerShell on Windows)
- The server's IP address and its password or SSH key
Almost every guide on this site starts the same way: "you need Docker on your server". This is that part, explained once and properly, so it doesn't have to be repeated in every tutorial.
Docker packages an application together with everything it needs to run. In practice that means installing Listmonk, Immich or Activepieces stops being an afternoon of broken dependencies and turns into two or three commands that behave the same on any server.
What you will need
A VPS with a clean Ubuntu install and root access. Almost any provider works; we recorded the process on a Hostinger VPS because their panel ships ready-made templates, but the commands are identical on DigitalOcean, Hetzner or Contabo.
1. Connect to the server over SSH
Open a terminal and log in with the IP your provider gave you:
ssh root@YOUR_SERVER_IP
The first time, it will ask whether you trust the machine. Type yes. If you are using a password, you will not see anything as you type it: that is normal, the terminal does not show asterisks.
2. Update the system before installing anything
apt update && apt upgrade -y
This step gets skipped often and it is the one that prevents half the strange problems. A system with old packages can install a version of Docker that does not match the documentation you are following.
3. Install Docker with the official script
Docker maintains a script that detects the distribution and sets up the correct repository:
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
It takes a minute or two. When it finishes, Docker is already running as a system service.
4. Give your user permissions
By default only root can talk to Docker. Working as root all the time is a bad idea, so add your user to the docker group:
usermod -aG docker $USER
And now the part that confuses everyone: that change does not apply until you log out and log back in. Type exit, connect again over SSH and continue.
5. Check that it worked
docker run hello-world
If you see a message starting with "Hello from Docker!", you are done. That command downloaded a minimal image, ran it and shut it down: you just completed the whole cycle.
It is also worth checking the version and that the service starts on its own:
docker --version
systemctl is-enabled docker
The second one should answer enabled. If it says disabled, turn it on with systemctl enable docker or your containers will not come back after a reboot.
Common mistakes
Installing docker.io from the Ubuntu repositories. It works, but it tends to lag several versions behind and does not include the modern Compose plugin. Tutorials that use docker compose (no hyphen) will fail.
Mixing up docker-compose and docker compose. The first is the old Python tool that had to be installed separately. The second is the current plugin and it comes with the official script. If a tutorial uses the hyphen, it is probably from before 2023.
Leaving the application's port open to the internet. Many containers publish their port on every interface. Before exposing anything, put a reverse proxy with HTTPS in front, or at least restrict access with the firewall.
Alternatives
If the command line is not your thing, there are two paths to the same place:
- Coolify gives you a panel on top of Docker to deploy applications with clicks. It is still your server and your data, just with an interface.
- ServerAvatar and similar panels manage the whole server, not only the containers. They cost a subscription but remove a fair amount of friction.
Neither saves you from understanding what a container is. They only save you from typing it.
Frequently asked questions
Do I need Docker if I am only going to run a WordPress site?
No. For a single WordPress site, managed hosting makes more sense: someone else handles updates and backups. Docker starts to pay off when you want to run several different applications on the same server.
How much RAM does a VPS need for Docker?
Docker itself uses very little. The weight comes from the containers. With 2 GB you can comfortably run two or three light applications; for large databases or several applications at once, start at 4 GB.
Is Docker Desktop the same thing?
No. Docker Desktop is the desktop version for Windows and macOS, with a graphical interface. On a server you install Docker Engine, which is just the engine and is driven from the command line.
What happens if I reboot the server?
Docker starts on its own, but containers do not, unless you created them with a restart policy. Add `--restart unless-stopped` when creating them, or `restart: unless-stopped` in the compose file.



