---
title: "How to install Docker on Ubuntu 22.04 or 24.04 on a VPS (straight to the point) | StreetHosting"
description: "A step-by-step guide to installing Docker Engine from the official repo on an Ubuntu LTS VPS: repository, group, hello-world, Compose plugin and security."
url: "https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps"
type: "page"
language: "en-US"
---

VPS · 3 min · Intermediate

Published on May 19, 2026 · Updated on May 20, 2026

# How to install Docker on Ubuntu on a VPS

A stable Docker install on an Ubuntu VPS depends on the right package source and step by step validation. In this guide you set up the official repository, install Engine and Compose, test the daemon and apply basic security measures before deploying applications.

By [Equipe StreetHosting](https://streethosting.com.br/en/autores#equipe-streethosting) · StreetHosting infrastructure and support team

[Linux administration](https://streethosting.com.br/en/guides/topics/linux) [Containers and Docker](https://streethosting.com.br/en/guides/topics/docker) [Hardware and datacenter](https://streethosting.com.br/en/guides/topics/hardware)

Summarize with:

[](https://chat.openai.com/?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Finstall-docker-ubuntu-vps.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "ChatGPT") [](https://claude.ai/new?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Finstall-docker-ubuntu-vps.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Claude") [](https://www.google.com/search?udm=50&aep=11&q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Finstall-docker-ubuntu-vps.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Google AI Mode") [](https://x.com/i/grok?text=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Finstall-docker-ubuntu-vps.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Grok") [](https://www.perplexity.ai/search/new?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Finstall-docker-ubuntu-vps.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Perplexity")

Share:

[](https://x.com/intent/tweet?text=How%20to%20install%20Docker%20on%20Ubuntu%2022.04%20or%2024.04%20on%20a%20VPS%20%28straight%20to%20the%20point%29&url=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Finstall-docker-ubuntu-vps "Share on X") [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Finstall-docker-ubuntu-vps "Share on Facebook") [](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Finstall-docker-ubuntu-vps "Share on LinkedIn") [](https://wa.me/?text=How%20to%20install%20Docker%20on%20Ubuntu%2022.04%20or%2024.04%20on%20a%20VPS%20%28straight%20to%20the%20point%29%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Finstall-docker-ubuntu-vps "Share on WhatsApp")

For agents: Copy as Markdown [.md](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps.md)

[Next How to secure SSH on a Linux VPS: keys, passwords, fail2ban](https://streethosting.com.br/en/guides/vps/secure-ssh-linux-vps)

In this guide 5 sections

* [Why the official repository](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#por-que-repositorio-oficial)
* [Prerequisites and updates](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#pre-requisitos-e-atualizacao)
* [Installing Engine and Compose](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#instalacao-engine-e-compose)
* [Validation and the docker user](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#validacao-e-usuario-docker)
* [Post-install security](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#seguranca-pos-install)

Quick answer

To install Docker on Ubuntu 22.04 or 24.04 on your VPS, use the official repository, validate the daemon with a simple test and only publish services after reviewing the firewall and SSH access. This order avoids a fast setup that carries high risk.

## Why the official repository[](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#por-que-repositorio-oficial)

The main reason to use the official repository is consistency. The daemon, CLI and plugins evolve together, which reduces mixed version errors in production. When something fails, the official documentation tends to match what is installed on the server.

If your VPS still accepts passwords over SSH, fix that before installing, so you avoid unnecessary exposure at the start of operation. See [secure SSH on a Linux VPS](https://streethosting.com.br/en/guides/vps/secure-ssh-linux-vps).

## Prerequisites and updates[](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#pre-requisitos-e-atualizacao)

* A VPS running Ubuntu LTS with administrative access via sudo.
* Recovery console enabled for access emergencies.
* Ubuntu version confirmed, so you use the correct codename in the repository.

### Patch cycle

Containers share the host kernel. That is why keeping the base system updated is part of Docker security. Plan a recurring update window so pending updates do not pile up.

## Installing Engine and Compose[](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#instalacao-engine-e-compose)

Install through the official flow: GPG key in a keyring, repository entry for your Ubuntu release, apt update and installation of the recommended packages. Do not copy old commands without checking the version.

On an unstable connection, use tmux so you do not lose your session during installation and package updates.

| Component      | Role                | Note                             |
| -------------- | ------------------- | -------------------------------- |
| docker-ce      | Main daemon         | Controls the container lifecycle |
| containerd     | Runtime             | Handles low level execution      |
| compose plugin | Local orchestration | Defines the stack in a YAML file |

## Validation and the docker user[](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#validacao-e-usuario-docker)

1. Start and enable the Docker service with systemd.
2. Run `hello-world` to validate communication with the daemon.
3. Check the Compose plugin version.
4. Optionally, add a trusted user to the docker group.

A user in the docker group can gain elevated privileges. Treat this access as administrative and review it periodically.

## Post-install security[](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#seguranca-pos-install)

Avoid exposing the Docker API publicly. Keep the socket local and, when necessary, manage it remotely through an SSH tunnel. Also apply [UFW firewall rules on an Ubuntu VPS](https://streethosting.com.br/en/guides/vps/ufw-firewall-ubuntu-vps) with ports open only for services you actually publish.

For automation workloads, also see [hosting n8n on a VPS in Brazil](https://streethosting.com.br/en/guides/vps/host-n8n-vps-brazil) and compare it with the [Ryzen VPS](https://streethosting.com.br/en/vps/ryzen) if you want less manual configuration. For a general purpose VPS, see the [StreetHosting Ryzen VPS](https://streethosting.com.br/en/vps/ryzen).

* Define a cleanup policy for old images and volumes.
* Keep sensitive variables in a secure environment.
* Back up compose files and persistent data.
* Update base images on a regular review routine.

In this guide

* [Why the official repository](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#por-que-repositorio-oficial)
* [Prerequisites and updates](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#pre-requisitos-e-atualizacao)
* [Installing Engine and Compose](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#instalacao-engine-e-compose)
* [Validation and the docker user](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#validacao-e-usuario-docker)
* [Post-install security](https://streethosting.com.br/en/guides/vps/install-docker-ubuntu-vps#seguranca-pos-install)

## Frequently asked questions

Is the Snap version of Docker acceptable?

It can work for a lab, but in production the official Docker repository tends to be more predictable for updates and compatibility.

Will I need Kubernetes later?

On most single VPS projects, no. Compose handles web services, workers and a database well, with less operational overhead.

Does Docker open all ports?

Publishing with -p 0.0.0.0 exposes the service on the public interface if the firewall allows it. Combine explicit publishing with a restrictive UFW setup, as covered in the firewall guide.

Does Ubuntu 24.04 change anything?

Mostly the codename and a few base dependencies. Follow the version specific commands to avoid ending up with the wrong repository.

Next step

See Ryzen VPS

Ryzen 9 9950X VPS in São Paulo with root access, NVMe and gamer Anti-DDoS.

[See Ryzen VPS](https://streethosting.com.br/en/vps/ryzen)

[See VPS plans Root VPS in Brazil with NVMe and Anti-DDoS.](https://streethosting.com.br/en/vps)

## Related guides

[VPS Beginner UFW on Ubuntu VPS: firewall rules without losing SSH UFW makes the Ubuntu firewall simpler, but one rule in the wrong order locks you out of your VPS. Learn how to enable it without losing SSH, open only what you need, deal with Docker, and get back in through the console if something goes wrong. 10 min Read guide](https://streethosting.com.br/en/guides/vps/ufw-firewall-ubuntu-vps) [VPS Intermediate How to secure SSH on a Linux VPS: keys, passwords, fail2ban SSH is usually the first target on any VPS with a public IP. This guide walks through a practical routine that cuts the risk without complicating your day: an ED25519 key, password-free login, admin access through sudo, blocking of automated attempts and a periodic review of authorized keys. 4 min Read guide](https://streethosting.com.br/en/guides/vps/secure-ssh-linux-vps) [VPS Intermediate Host n8n on a VPS in Brazil: low-latency automation and best practices Hosting n8n on a VPS in Brazil helps with integrations that depend on local APIs and predictable response times. This guide covers a Docker-based architecture, a TLS proxy, credential protection and a backup strategy so you never lose your workflows. 4 min Read guide](https://streethosting.com.br/en/guides/vps/host-n8n-vps-brazil)

[← Back to the Guide Center](https://streethosting.com.br/en/guides)
