How to Install Docker on Ubuntu 24.04

|
Last Updated:
|
|

In this tutorial, we are going to learn how to install Docker on Ubuntu 24.04. Docker is a platform that enables developers and system administrators to build, run, and share applications in containers.

Installing Docker on Ubuntu 24.04

There exits two editions of docker available. Docker CE and Docker EE.

  • Docker (Community Edition) is the open-source, community supported version of Docker and is available for free.
  • Docker EE (Enterprise Edition) is a commercial/premium version of Docker and is support by Docker Inc.

There are different methods in which you can install Docker;

Installing Docker on Ubuntu 24.04 from Docker Repositories

Install Docker repository GPG signing key.

To install Docker from Docker, you first need to install some required packages by executing the command below. Some of the package may already be installed though;

sudo apt update
sudo apt install apt-transport-https \
	ca-certificates \
	curl \
	gnupg-agent \
	software-properties-common

Next, install Docker repository GPG signing key.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg

Install Docker Repository on Ubuntu 24.04

Run the command below to install Docker repository on Ubuntu 24.04.

Note that as of this writing, Docker-CE repos is not yet available for Ubuntu 24.04 Noble Numbat. We will use Docker repos for Ubuntu 22.04 Jammy for now. However, if you want, you can install the Docker packages that ships with Ubuntu 24.04 by default, docker.io. This may not provide the latest release versions of Docker though.

echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable" \ | sudo tee /etc/apt/sources.list.d/docker-ce.list

Update System Package Cache

After that, update package cache.

sudo apt update

Install Docker from Docker Repository

Install Docker and other tools including containerd.io, An open and reliable container runtime.

sudo apt install docker-ce docker-ce-cli containerd.io

Note that, even if you install just docker-ce package, other tools like docker-ce-cli and containerd.io will be installed along with it.

sudo apt install docker-ce
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  docker-buildx-plugin docker-ce-rootless-extras docker-compose-plugin git git-man liberror-perl libslirp0 pigz slirp4netns
Suggested packages:
  aufs-tools cgroupfs-mount | cgroup-lite git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin git git-man liberror-perl libslirp0 pigz
  slirp4netns
0 upgraded, 12 newly installed, 0 to remove and 7 not upgraded.
Need to get 122 MB of archives.
After this operation, 444 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://de.archive.ubuntu.com/ubuntu noble/universe amd64 pigz amd64 2.8-1 [65.6 kB]
Get:2 https://download.docker.com/linux/ubuntu jammy/stable amd64 containerd.io amd64 1.6.28-1 [29.6 MB]
Get:3 http://de.archive.ubuntu.com/ubuntu noble/main amd64 liberror-perl all 0.17029-2 [25.6 kB]
Get:4 http://de.archive.ubuntu.com/ubuntu noble/main amd64 git-man all 1:2.43.0-1ubuntu1 [1,100 kB]
Get:5 http://de.archive.ubuntu.com/ubuntu noble/main amd64 git amd64 1:2.43.0-1ubuntu1 [3,677 kB]
Get:6 https://download.docker.com/linux/ubuntu jammy/stable amd64 docker-buildx-plugin amd64 0.12.1-1~ubuntu.22.04~jammy [28.2 MB]
Get:7 https://download.docker.com/linux/ubuntu jammy/stable amd64 docker-ce-cli amd64 5:25.0.3-1~ubuntu.22.04~jammy [13.7 MB]
Get:8 https://download.docker.com/linux/ubuntu jammy/stable amd64 docker-ce amd64 5:25.0.3-1~ubuntu.22.04~jammy [24.3 MB]
Get:9 http://de.archive.ubuntu.com/ubuntu noble/main amd64 libslirp0 amd64 4.7.0-1ubuntu1 [63.2 kB]
Get:10 http://de.archive.ubuntu.com/ubuntu noble/universe amd64 slirp4netns amd64 1.2.1-1 [34.5 kB]
Get:11 https://download.docker.com/linux/ubuntu jammy/stable amd64 docker-ce-rootless-extras amd64 5:25.0.3-1~ubuntu.22.04~jammy [9,313 kB]
Get:12 https://download.docker.com/linux/ubuntu jammy/stable amd64 docker-compose-plugin amd64 2.24.5-1~ubuntu.22.04~jammy [12.1 MB]
Fetched 122 MB in 1s (93.0 MB/s)                      
Selecting previously unselected package pigz.
(Reading database ... 156408 files and directories currently installed.)
Preparing to unpack .../00-pigz_2.8-1_amd64.deb ...
Unpacking pigz (2.8-1) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../01-containerd.io_1.6.28-1_amd64.deb ...
Unpacking containerd.io (1.6.28-1) ...
Selecting previously unselected package docker-buildx-plugin.
Preparing to unpack .../02-docker-buildx-plugin_0.12.1-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-buildx-plugin (0.12.1-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../03-docker-ce-cli_5%3a25.0.3-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce-cli (5:25.0.3-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../04-docker-ce_5%3a25.0.3-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce (5:25.0.3-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../05-docker-ce-rootless-extras_5%3a25.0.3-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:25.0.3-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-compose-plugin.
Preparing to unpack .../06-docker-compose-plugin_2.24.5-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-compose-plugin (2.24.5-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../07-liberror-perl_0.17029-2_all.deb ...
Unpacking liberror-perl (0.17029-2) ...
Selecting previously unselected package git-man.
Preparing to unpack .../08-git-man_1%3a2.43.0-1ubuntu1_all.deb ...
Unpacking git-man (1:2.43.0-1ubuntu1) ...
Selecting previously unselected package git.
Preparing to unpack .../09-git_1%3a2.43.0-1ubuntu1_amd64.deb ...
Unpacking git (1:2.43.0-1ubuntu1) ...
Selecting previously unselected package libslirp0:amd64.
Preparing to unpack .../10-libslirp0_4.7.0-1ubuntu1_amd64.deb ...
Unpacking libslirp0:amd64 (4.7.0-1ubuntu1) ...
Selecting previously unselected package slirp4netns.
Preparing to unpack .../11-slirp4netns_1.2.1-1_amd64.deb ...
Unpacking slirp4netns (1.2.1-1) ...
Setting up liberror-perl (0.17029-2) ...
Setting up docker-buildx-plugin (0.12.1-1~ubuntu.22.04~jammy) ...
Setting up containerd.io (1.6.28-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up docker-compose-plugin (2.24.5-1~ubuntu.22.04~jammy) ...
Setting up docker-ce-cli (5:25.0.3-1~ubuntu.22.04~jammy) ...
Setting up libslirp0:amd64 (4.7.0-1ubuntu1) ...
Setting up pigz (2.8-1) ...
Setting up git-man (1:2.43.0-1ubuntu1) ...
Setting up docker-ce-rootless-extras (5:25.0.3-1~ubuntu.22.04~jammy) ...
Setting up slirp4netns (1.2.1-1) ...
Setting up docker-ce (5:25.0.3-1~ubuntu.22.04~jammy) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Setting up git (1:2.43.0-1ubuntu1) ...
Processing triggers for man-db (2.12.0-3) ...
Processing triggers for libc-bin (2.38-3ubuntu1) ...

Installing Docker using DEB Binary Package

If you want to go the manual way, you can simply download Docker DEB binary package for your specific system version from https://download.docker.com/linux/ubuntu/dists/.

For example, in this case to download the DEB binary packages for Ubuntu 22.04 Jammy (Packages for Ubuntu 24.04 Noble is not yet available as of this writing), navigate to https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/ and grab the .deb files.

To download docker-ce, docker-ce-cli and containerd.io, you would simply pull them as follows;

wget https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce_25.0.3-1~ubuntu.22.04~jammy_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce-cli_25.0.3-1~ubuntu.22.04~jammy_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/containerd.io_1.6.28-1_amd64.deb

You can then install them using the apt or dpkg package manager. Be sure to install docker-ce-cli and containerd.io before docker-ce.

sudo apt install ./docker-ce-cli_25.0.3-1~ubuntu.22.04~jammy_amd64.deb
sudo apt install ./containerd.io_1.6.28-1_amd64.deb
sudo apt install ./docker-ce_25.0.3-1~ubuntu.22.04~jammy_amd64.deb

Checking Installed Docker Version

To check the version of installed Docker, simply run the command;

docker --version
Docker version 25.0.3, build 4debf41

Starting Docker Service

To start and enable Docker and Containerd service to run on system boot;

sudo systemctl enable --now docker containerd

Running Docker as a non-root user

If you run Docker as standard system user, you may get such an error;

docker run hello-world
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: ...
/var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

Therefore, if you need to run docker as non-root user, simply add the user you want to run docker as to docker group or simply, grant the user sudo rights. For example to add current user to docker group;

sudo usermod -aG docker $USER

Once you have added the user to the Docker group, log out and login again to have the user group membership re-evaluated.

You can then run docker as the standard user.

Verifying Docker installation

To verify that Docker is running well, you can try running the hello-world container image.

docker run hello-world

NOTE: If you still get the same permission denied error after adding user to docker group, logout and login again and you should be able to run docker as a standard user.

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete 
Digest: sha256:4bd78111b6914a99dbc560e6a20eab57ff6655aea4a80c50b0c5491968cbc2e6
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

To list running containers;

docker ps -a
CONTAINER ID   IMAGE         COMMAND    CREATED              STATUS                          PORTS     NAMES
738e19789531   hello-world   "/hello"   About a minute ago   Exited (0) About a minute ago             naughty_jones

Display system-wide Docker information;

docker system info
Client: Docker Engine - Community
 Version:    25.0.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.5
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 1
 Server Version: 25.0.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.6.0-14-generic
 Operating System: Ubuntu Noble Numbat (development branch)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.827GiB
 Name: noble-numbat
 ID: c705c75f-87dd-4180-8982-93967e9129a8
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

There you go. You have successfully installed Docker on Ubuntu 24.04. You can now explore Docker further.

Reference

Docker Engine Installation on Ubuntu

Other Tutorials

Monitor Docker Swarm Node Metrics using Grafana

Monitor Docker Containers Metrics using Grafana

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
Kifarunix
Linux Certified Engineer, with a passion for open-source technology and a strong understanding of Linux systems. With experience in system administration, troubleshooting, and automation, I am skilled in maintaining and optimizing Linux infrastructure.

Leave a Comment