Docker Installation: Install Docker Engine on Ubuntu 24.04 and Rocky Linux 9

·1068 words

This guide covers Ubuntu 24.04 LTS and Rocky Linux 9. For other versions, check the Docker documentation in the references for supported releases and repository setup.

Common commands at a glance
#

Follow the setup steps for Ubuntu 24.04 LTS or Rocky Linux 9. The commands below apply to both systems after installation.

CommandWhat it does
sudo systemctl enable --now dockerStart Docker and enable it at boot
sudo systemctl status docker --no-pagerCheck the Docker service status
sudo docker versionCheck the Docker CLI and Engine versions
sudo docker compose versionCheck the Compose plugin
sudo docker buildx versionCheck the Buildx plugin
sudo docker run hello-worldRun a test container to verify the installation

Docker Engine and its components
#

At the center of Docker Engine is the Docker daemon, a service that runs in the background. It manages images, containers, and networks with the help of components such as containerd. The Docker CLI provides the docker command and sends requests to the daemon through its API.

This guide installs Docker Engine, the CLI, and the Buildx and Compose plugins. Buildx builds images and Compose manages multi-container applications. Docker Desktop is a separate product with a graphical interface.

Docker CE, Docker EE, and MCR

NameWhat it meansHow this guide treats it
Docker CECommunity Edition. This guide installs it from Docker’s official repository as the docker-ce package.The installation path used here.
Docker EEEnterprise Edition, Docker’s former enterprise product. Mirantis acquired the Docker Enterprise business in 2019.A historical name, not another package option in this guide.
Mirantis Container Runtime (MCR)An enterprise container runtime product provided and supported by Mirantis.A separate Mirantis product and support path; not installed in this guide.

Product positioning can change. This guide uses Mirantis’ current product page as well as the historical acquisition announcement for its description of MCR.

Pre-installation checks
#

Use cat /etc/os-release to check the distribution and release, and uname -m to check the machine architecture.

Shell
cat /etc/os-release
uname -m

If you’ve installed Docker or other container tools before

Existing packages such as docker.io, containerd, and podman-docker may conflict with Docker’s official packages. Check these two points before removing a package.

  • Are these packages being used by other services?
  • Does /var/lib/docker contain images or container data you need to keep?

Resolve package conflicts with the package manager. Assess and back up the data directory separately.

Installing on Ubuntu 24.04 LTS
#

Ubuntu’s package manager is APT. What we need to do: add Docker’s official repository, import the GPG key, and install the packages.

Shell
# Add Docker's official GPG key:
sudo apt update
sudo apt install ca-certificates curl
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

# Add the repository to Apt sources:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

Install the Docker packages.

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

Using Signed-By here specifies the GPG key so it’s only used to verify Docker repository packages, not affecting other repositories’ verification.

If you need a specific version (like locking versions in production), first use apt-cache madison docker-ce to check available versions, then specify the version number for installation. Here we’re installing the latest stable version for convenience.

Installing on Rocky Linux 9
#

Rocky Linux uses the DNF package manager, as do many RPM-based distributions. The steps are similar to Ubuntu but the commands differ.

Shell
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/rocky/docker-ce.repo

If DNF asks whether to trust the repository key during installation, compare the displayed fingerprint with 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35 before accepting. Docker publishes this value in the Rocky Linux installation guide.

Shell
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Starting and verifying
#

Both systems use systemd to manage services, so the startup commands are the same:

Shell
# Start Docker service and enable it to start on boot
sudo systemctl enable --now docker

# Check service status
sudo systemctl status docker --no-pager

Use the following commands to verify the Docker service and the Compose and Buildx plugins.

Shell
sudo docker version
sudo docker compose version
sudo docker buildx version
sudo docker run hello-world

docker version should show both Client and Server information, which confirms that the client can reach the daemon. docker compose version and docker buildx version should each print a plugin version. Docker downloads the hello-world image if it is missing locally. The message Hello from Docker! confirms that the example container ran successfully.

Docker daemon access and user permissions
#

With this installation, the Docker daemon runs as root. Regular users can run Docker commands with sudo. Members of the docker group can also access the daemon. They can mount the host filesystem or run privileged containers, which gives them privileges equivalent to root.

If that level of access is appropriate for the environment, add the user to the docker group.

Shell
sudo usermod -aG docker $USER

Log back in or run newgrp docker to apply the new group membership. In production, restrict access to the Docker daemon to authorized accounts.

Common issues
#

docker version only shows Client, no Server

Read the error in the Server section. On a connection failure, check the service with sudo systemctl status docker and its logs with sudo journalctl -u docker -n 50. If access is denied, compare with sudo docker version. For remote contexts, check the selected endpoint with docker context ls.

Package conflicts during installation

Before removing a package, check what it does, which services depend on it, and what data you need to retain from /var/lib/docker.

Failed to pull images

Use the error message to distinguish network or DNS failures, proxy configuration, registry authentication, and rate limiting. A failed pull does not by itself prove that the Docker installation is broken.

Compose/Buildx commands not found

Confirm that docker-compose-plugin and docker-buildx-plugin are installed. This guide uses the supported Compose plugin command docker compose. The standalone Compose V1 command docker-compose is no longer maintained and is not part of the new installation path.

References
#