In this guide, we are going to learn how to install Docker on Ubuntu with step-by-step complete explanation. We will also verify every step to make sure Docker is properly installed and running on your system.
Topics Covered:
- How to update and prepare your Ubuntu system
- How to install Docker securely using Docker’s official repository
- How to verify Docker installation
- How to test Docker by running a container
My Setup:
I'm using Ubuntu 22.04 as my operating system for this demo.
You can also watch this tutorial demo on our Youtube Channel
Step 1: Update System Packages
We need to update the package list and upgrade any outdated packages.
sudo apt updatesudo apt upgrade -y
Command Output:
TrimmedProcessing triggers for dbus (1.14.10-4ubuntu4.1) ...Processing triggers for install-info (7.1-3build2) ...Processing triggers for libc-bin (2.39-0ubuntu8.5) ...Processing triggers for man-db (2.12.0-4build2) ...Processing triggers for initramfs-tools (0.142ubuntu25.5) ...update-initramfs: Generating /boot/initrd.img-6.8.0-64-genericScanning processes...Scanning candidates...Scanning linux images...Running kernel seems to be up-to-date.Restarting services...systemctl restart multipathd.service polkit.service ssh.service udisks2.serviceService restarts being deferred:systemctl restart ModemManager.service/etc/needrestart/restart.d/dbus.servicesystemctl restart getty@tty1.servicesystemctl restart systemd-logind.servicesystemctl restart unattended-upgrades.serviceNo containers need to be restarted.User sessions running outdated binaries:skuma @ session #2: apt[1490], sshd[891]skuma @ session #4: sshd[893]skuma @ user manager service: systemd[898]No VM guests are running outdated hypervisor (qemu) binaries on this host.skuma@server1:~$
This makes sure we are working with the latest versions of all dependencies.
Step 2: Install Required Packages
Install some necessary packages that help us securely install Docker.
sudo apt install ca-certificates curl gnupg -y
Command Output:
skuma@server1:~$ sudo apt install ca-certificates curl gnupg -yReading package lists... DoneBuilding dependency tree... DoneReading state information... Doneca-certificates is already the newest version (20240203).ca-certificates set to manually installed.curl is already the newest version (8.5.0-2ubuntu10.6).gnupg is already the newest version (2.4.4-2ubuntu17.3).gnupg set to manually installed.0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.skuma@server1:~$
These tools are very important for managing repositories and downloading packages over HTTPS.
Step 3: Add Docker’s GPG Key
To make sure we install Docker from a trusted source, we need to add Docker’s official GPG key.
First, create the directory:
sudo mkdir -p /etc/apt/keyrings
Then download and store the GPG key securely using curl:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg \--dearmor -o /etc/apt/keyrings/docker.gpg
Step 4: Add Docker’s Repository
Now we’ll add Docker’s official repository.
echo \"deb [arch=$(dpkg --print-architecture) \signed-by=/etc/apt/keyrings/docker.gpg] \https://download.docker.com/linux/ubuntu \$(lsb_release -cs) stable" | \sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
This command automatically detects your system architecture and Ubuntu version, and configures the Docker repo accordingly.
Step 5: Update the Package List Again
Now that Docker's repo is added, we need to refresh the package list again.
sudo apt update
Command Output:
skuma@server1:~$ sudo apt updateGet:1 https://download.docker.com/linux/ubuntu noble InRelease [48.8 kB]Get:2 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages [28.5 kB]Hit:3 http://in.archive.ubuntu.com/ubuntu noble InReleaseHit:4 http://security.ubuntu.com/ubuntu noble-security InReleaseHit:5 http://in.archive.ubuntu.com/ubuntu noble-updates InReleaseHit:6 http://in.archive.ubuntu.com/ubuntu noble-backports InReleaseFetched 77.3 kB in 2s (47.0 kB/s)Reading package lists... DoneBuilding dependency tree... DoneReading state information... Done4 packages can be upgraded. Run 'apt list --upgradable' to see them.
Step 6: Install Docker Engine
Now comes the main part, installing Docker.
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
Command Output:
skuma@server1:~$ sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -yReading package lists... DoneBuilding dependency tree... DoneReading state information... DoneThe following additional packages will be installed:docker-ce-rootless-extras libslirp0 pigz slirp4netnsSuggested packages:cgroupfs-mount | cgroup-lite docker-model-pluginThe following NEW packages will be installed:containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin libslirp0 pigz slirp4netns0 upgraded, 9 newly installed, 0 to remove and 4 not upgraded.Need to get 103 MB of archives.After this operation, 429 MB of additional disk space will be used.Output TrimmedRunning kernel seems to be up-to-date.Restarting services...Service restarts being deferred:/etc/needrestart/restart.d/dbus.servicesystemctl restart getty@tty1.servicesystemctl restart systemd-logind.servicesystemctl restart unattended-upgrades.serviceNo containers need to be restarted.User sessions running outdated binaries:skuma @ session #2: sshd[891]skuma @ session #4: sshd[893]skuma @ user manager service: systemd[898]No VM guests are running outdated hypervisor (qemu) binaries on this host.skuma@server1:~$
This installs:
Docker Engine
Docker CLI tools
Docker Compose plugin
Step 7: Verify Docker Installation
Check Docker version:
docker --version
Command Output:
skuma@server1:~$ docker --versionDocker version 28.3.2, build 578ccf6skuma@server1:~$
If you see the version number, Docker is installed correctly.
Step 8: Check Docker Service Status
Verify whether Docker is running or not.
sudo systemctl status docker
Command Output:
skuma@server1:~$ sudo systemctl status docker● docker.service - Docker Application Container EngineLoaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled)Active: active (running) since Sat 2025-07-26 05:23:22 UTC; 1min 6s agoTriggeredBy: ● docker.socketDocs: https://docs.docker.comMain PID: 16697 (dockerd)Tasks: 8Memory: 21.6M (peak: 21.8M)CPU: 483msCGroup: /system.slice/docker.service└─16697 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sockJul 26 05:23:21 server1 dockerd[16697]: time="2025-07-26T05:23:21.669297451Z" level=info msg="detected 127.0.0.53 nameserver, assuming systemd-resolved, so using re>Jul 26 05:23:21 server1 dockerd[16697]: time="2025-07-26T05:23:21.708933067Z" level=info msg="Creating a containerd client" address=/run/containerd/containerd.sock >Jul 26 05:23:21 server1 dockerd[16697]: time="2025-07-26T05:23:21.824117058Z" level=info msg="Loading containers: start."Jul 26 05:23:22 server1 dockerd[16697]: time="2025-07-26T05:23:22.404568741Z" level=info msg="Loading containers: done."Jul 26 05:23:22 server1 dockerd[16697]: time="2025-07-26T05:23:22.436489743Z" level=info msg="Docker daemon" commit=e77ff99 containerd-snapshotter=false storage-dri>Jul 26 05:23:22 server1 dockerd[16697]: time="2025-07-26T05:23:22.436901615Z" level=info msg="Initializing buildkit"Jul 26 05:23:22 server1 dockerd[16697]: time="2025-07-26T05:23:22.501542109Z" level=info msg="Completed buildkit initialization"Jul 26 05:23:22 server1 dockerd[16697]: time="2025-07-26T05:23:22.518178178Z" level=info msg="Daemon has completed initialization"Jul 26 05:23:22 server1 dockerd[16697]: time="2025-07-26T05:23:22.518243119Z" level=info msg="API listen on /run/docker.sock"Jul 26 05:23:22 server1 systemd[1]: Started docker.service - Docker Application Container Engine.
You should see something like active (running) in green. That means Docker is up and running.
Step 9: Run a Test Container
Let’s run a simple test container using the hello-world image:
sudo docker run hello-world
Command Output:
skuma@server1:~$ sudo docker run hello-worldUnable to find image 'hello-world:latest' locallylatest: Pulling from library/hello-worlde6590344b1a5: Pull completeDigest: sha256:ec153840d1e635ac434fab5e377081f17e0e15afab27beb3f726c3265039cfffStatus: Downloaded newer image for hello-world:latestHello 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare 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/skuma@server1:~$
This downloads a test image and runs a small container.
If everything is working, you'll see a friendly message from Docker confirming the setup is successful.
That’s It!
We have successfully installed Docker on Ubuntu 22.04! See you in the next tutorial.
0 Comments