How to Install Docker on Ubuntu 24.04

Contents

Docker is one of the most practical ways to run applications in isolated containers. On a VPS, it helps you deploy services faster, separate workloads cleanly, and move environments between servers more predictably.

On Ubuntu 24.04, Docker installation is straightforward, but it is worth doing properly: from the official repository, with the correct key setup, service checks, and a basic understanding of user permissions and exposed ports.

What to check before you start

Before enabling Docker on a server, make sure that:

  • you have SSH access to the server;
  • the system is updated;
  • you have a sudo-enabled user;
  • there is enough free disk space for images and containers;
  • you understand which services will later be exposed to the network.

If the VPS is already used in production, it is better to treat Docker installation as part of infrastructure setup, not just as a quick package install.

Step 1. Update system packages

Start by refreshing package indexes and installing current updates:

sudo apt update
sudo apt upgrade -y

Step 2. Install dependencies for Docker repository setup

Install the required packages:

sudo apt install -y ca-certificates curl gnupg

Step 3. Add the official Docker GPG key

Create the key directory and download the official key:

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Step 4. Add the official Docker repository

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Then update package indexes again:

sudo apt update

Step 5. Install Docker Engine

sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

This installs:

  • docker-ce — Docker Engine;
  • docker-ce-cli — command-line tools;
  • containerd.io — container runtime;
  • docker-buildx-plugin — modern image build tooling;
  • docker-compose-plugin — Compose as a Docker plugin.

Step 6. Verify Docker is running

Check service status:

sudo systemctl status docker

Check version:

docker --version

Run a test container:

sudo docker run hello-world

Step 7. Allow Docker without sudo

If you want to run Docker commands without sudo, add your user to the docker group:

sudo usermod -aG docker $USER

Then re-login or run:

newgrp docker

Verify:

docker ps
Important: membership in the docker group effectively gives broad control over the host. Do not grant it casually on production servers.

Step 8. Verify autostart

sudo systemctl enable docker
sudo systemctl enable containerd

Docker Compose note

On modern Ubuntu setups, Compose is usually used as a plugin:

docker compose version

Preferred syntax:

docker compose up -d

Older guides may still show:

docker-compose up -d

Ports and firewall

When you publish a container port, such as:

docker run -d -p 8080:80 nginx

that service may become externally reachable. This is why Docker and firewall rules must be considered together, especially on a real VPS.

What infrastructure fits Docker projects

If you plan to run websites, APIs, bots, automation services, or AI tools in containers, start with a predictable server environment where you control networking, resources, volumes, restarts, and access.

For most standard container projects, VPS is enough. If the workload grows and you need stricter resource isolation, look at dedicated servers.

  • VPS — for most early-stage container projects;
  • dedicated servers — when you need stronger resource guarantees and isolation.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

    We use a variety of tools, including cookies, to provide the basic services and functionality of our site, and to collect data about how visitors interact with our site, products and services. By clicking "Accept", you agree to the current terms and conditions of use of the site and give permission to use this data. Otherwise, please leave the site.

    Spelling error report

    The following text will be sent to our editors: