Docker goes on a VPS with root access over SSH, never on shared hosting: there is no way to run it there. We recommend Ubuntu 22.04 LTS, the one with the most documentation. The right installation is the one in the official Docker documentation (Install Docker Engine, Ubuntu), which changes from time to time. So this article explains the order and the traps, and leaves the repository commands to the people who maintain them: Docker itself.
|
On an unmanaged VPS, installing and maintaining Docker and the applications running in it is your job. Our support looks after the server, the network and access; it does not install or repair third-party software. See how far our support goes and managed or unmanaged VPS.
|
The installation, in order
| 2 |
Update the system: sudo apt update sudo apt upgradeIf the update brings a new kernel, reboot the server before going on.
|
|
| 3 |
Remove old packages. If the VPS already carries Docker packages from another source (for example docker.io), the official documentation lists the ones to remove first. On a freshly ordered server there is normally nothing to remove.
|
|
| 4 |
Follow the official documentation at docs.docker.com, “Install Docker Engine on Ubuntu”, using the apt repository method: it adds Docker’s key and repository and then installs. Copy the commands from there, not from an old article.
|
|
| 5 |
Install the packages (once the repository is set up): sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|
| 6 |
Check that it works: sudo systemctl status docker sudo docker run hello-world docker compose versionThe hello-world image downloads a test image, runs it and prints a message. If you see it, Docker is up.
|
|
Installation methods
| Method |
What it is |
When |
| Docker’s apt repository |
The method the official documentation presents first. |
The normal choice on a real server. |
| Convenience script |
A script Docker publishes that does everything in one go. |
The documentation itself presents it as for testing and development, not production. |
| The distribution’s docker.io package |
A version packaged by the distribution, which may lag behind the official one. |
Avoid it if you are following Docker’s documentation. |
Compose comes included. The docker-compose-plugin package adds the docker compose command (with a space). The old docker-compose (with a hyphen) was a separate program, and it is what old guides still show. In this set of articles we always use the form with a space.
Using Docker without typing sudo
To let your own user (not root) run Docker directly: sudo usermod -aG docker $USERLog out of the SSH session and back in for the change to take effect.
|
Anyone in the docker group can, in practice, become root on the server. Docker lets you mount any folder of the server inside a container. Add only people who would already have root, and read the six things that keep a VPS secure.
|
|
Containers come back by themselves after a reboot if you give them a restart policy (restart: unless-stopped in Compose) and the Docker service is enabled at boot: sudo systemctl enable docker.
|
|
Do not have a VPS yet? See the plans and pick the operating system when you order.
See the VPS servers
|
RECOMMENDED PRODUCT VPS server with root access Resources of your own, the OS you choose, reinstall whenever you like. from $8.40/mo (3-year plan, with coupon) See plans |