How to Install Docker on Ubuntu 26.04, 24.04 and 22.04

Install Docker on Ubuntu 26.04, 24.04 and 22.04 using the official repository. Covers setup, verification, systemd management, security.

Last updatedAuthorJoshua JamesRead time13 minGuide typeUbuntu

Most CI pipelines, Compose files, and local development stacks expect Docker rather than only a compatible container runtime. To install Docker on Ubuntu 26.04, 24.04, or 22.04 LTS, use Docker’s official APT repository for the current Engine, Compose, and Buildx packages, or stay with Ubuntu’s docker.io packages when archive-managed updates matter more than upstream speed.

Docker Engine is the right target for CLI, server, desktop-terminal, and headless workflows. Docker Desktop is a separate GUI product and is not required for normal Docker Engine or Docker Compose usage on Ubuntu.

Install Docker on Ubuntu 26.04, 24.04, and 22.04

Quick Docker Install Commands for Ubuntu

On a clean Ubuntu 26.04, 24.04, or 22.04 system, the recommended official Docker install path is to add Docker’s APT repository, install Docker Engine with Compose and Buildx, then run the hello-world container. If the system already has Docker from another source, remove conflicting packages first so APT does not mix Docker’s packages with Ubuntu’s docker.io family.

sudo apt update

These commands use sudo for tasks that need root privileges. If your user is not in the sudoers file yet, run the commands as root or follow the guide on how to add a user to sudoers on Ubuntu.

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

printf '%s\n' \
'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' \
| sudo tee /etc/apt/sources.list.d/docker.sources > /dev/null

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run --rm hello-world

The same package-family distinction matters for version checks, Ubuntu’s docker.io alternative, and common Docker socket or repository errors.

Confirm Docker Support on Ubuntu 26.04, 24.04, and 22.04

Docker Engine for Ubuntu supports Ubuntu 26.04, 24.04, and 22.04 LTS on x86_64/amd64, arm64, armhf, s390x, and ppc64le (ppc64el) architectures; on x86_64 and arm64 this means a 64-bit Ubuntu install. See the Docker Engine install guide for Ubuntu for Docker’s canonical support list.

Choose a Docker Installation Method on Ubuntu

Docker is packaged by Docker Inc. and by Ubuntu. Pick one package family and stay with it; mixing the two methods can create conflicting daemon, containerd, and plugin packages.

MethodMain PackagesBest ForUpdate Cadence
Official Docker APT repositorydocker-ce, docker-compose-plugin, docker-buildx-pluginMost users on Ubuntu 26.04, 24.04, and 22.04 who want Docker’s upstream packagesFast, direct from Docker Inc.
Ubuntu docker.io packagesdocker.io, docker-compose-v2, docker-buildxSystems that avoid third-party APT sources or prefer Ubuntu-maintained packagesUbuntu-maintained, usually behind Docker’s repo

The package names are not interchangeable. Docker’s repository uses docker-compose-plugin and docker-buildx-plugin, while Ubuntu’s repositories use docker-compose-v2 and docker-buildx. If APT cannot locate docker-compose-plugin, either Docker’s repository is not enabled or you are using the Ubuntu package path.

Use the official Docker repository unless you specifically need the Ubuntu-maintained package set. Docker also publishes manual .deb downloads, but the APT repository is easier to update and keeps the engine, CLI, Compose, and Buildx packages aligned.

If you use ufw or firewalld, be aware that Docker manages iptables rules directly. Docker supports iptables-nft and iptables-legacy, but rules created with nft are not supported. Review Docker’s packet filtering and firewall guidance before proceeding.

Update Ubuntu Package Metadata for Docker

Refresh APT metadata before installing packages or changing repository sources:

sudo apt update

Remove Previous Docker Packages from Ubuntu

If you previously installed Docker from another source, remove older packages first to avoid conflicts. Use the Ubuntu package removal command if you installed docker.io, and the Docker Engine removal command if you installed docker-ce from Docker’s repository.

Remove Ubuntu-packaged Docker components:

sudo apt remove docker.io docker-doc docker-compose docker-compose-v2 docker-buildx podman-docker containerd runc

Remove Docker Engine packages from Docker’s repository if you installed them previously:

sudo apt remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

If you have not installed any of these packages, APT reports that nothing needs to be removed.

Preview orphaned dependencies before removing them. Continue only if the list contains packages you no longer need:

sudo apt autoremove --dry-run

If the preview only lists packages you are comfortable removing, run autoremove for real:

sudo apt autoremove

These commands permanently delete all Docker images, containers, volumes, and networks stored in /var/lib/docker/ and /var/lib/containerd/. Only run them if you want a completely clean Docker installation.

Delete existing Docker data if you want a fresh start:

sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

If you previously added Docker’s official repository, remove old source files and keyrings before recreating them:

sudo rm -f /etc/apt/sources.list.d/docker.sources
sudo rm -f /etc/apt/sources.list.d/docker.list
sudo rm -f /etc/apt/keyrings/docker.asc
sudo rm -f /usr/share/keyrings/docker.gpg

Refresh your package index after cleanup:

sudo apt update

Recommended Method: Install Docker Engine from Docker’s Official APT Repository

This method uses Docker’s upstream packages and includes the official Compose and Buildx plugins. It works on Ubuntu 26.04, 24.04, and 22.04.

Add Docker’s Official APT Repository on Ubuntu

Install the tools needed to download Docker’s signing key. If you are new to curl, see our curl command guide for examples.

sudo apt install ca-certificates curl

Create the APT keyrings directory, then download Docker’s current ASCII-armored signing key:

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

The install -m 0755 -d command creates the keyring directory with standard system-readable permissions, and chmod a+r lets APT read the key during repository checks.

Add Docker’s repository in DEB822 format. The command detects your Ubuntu codename and architecture automatically:

printf '%s\n' \
'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' \
| sudo tee /etc/apt/sources.list.d/docker.sources > /dev/null

Refresh your package index so APT reads the Docker repository:

sudo apt update

Relevant output on Ubuntu 26.04 includes Docker’s resolute repository:

Get:1 https://download.docker.com/linux/ubuntu resolute InRelease [26.2 kB]
Get:2 https://download.docker.com/linux/ubuntu resolute/stable amd64 Packages [10.5 kB]

Confirm that APT will install Docker from download.docker.com:

apt-cache policy docker-ce

Example output on Ubuntu 26.04:

docker-ce:
  Installed: (none)
  Candidate: 5:29.4.1-1~ubuntu.26.04~resolute
  Version table:
     5:29.4.1-1~ubuntu.26.04~resolute 500
        500 https://download.docker.com/linux/ubuntu resolute/stable amd64 Packages
     5:29.4.0-1~ubuntu.26.04~resolute 500
        500 https://download.docker.com/linux/ubuntu resolute/stable amd64 Packages
     5:29.3.1-1~ubuntu.26.04~resolute 500
        500 https://download.docker.com/linux/ubuntu resolute/stable amd64 Packages

Install Docker Engine, Compose, and Buildx on Ubuntu

Install Docker Engine and the official Compose and Buildx plugins:

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

Verify the installed versions:

docker --version
docker compose version
docker buildx version

Expected output from Docker’s repository currently resembles:

Docker version 29.4.1, build 055a478
Docker Compose version v5.1.3
github.com/docker/buildx v0.33.0 f7897eba028583e0071642db3c011e860444f8cf

Install a Specific Docker Engine Version on Ubuntu

Install the latest Docker release unless a workload, test environment, or compatibility requirement needs a specific Engine version. First list the versions available from Docker’s repository:

apt list --all-versions docker-ce

Relevant output on Ubuntu 26.04 currently includes:

docker-ce/resolute 5:29.4.1-1~ubuntu.26.04~resolute amd64
docker-ce/resolute 5:29.4.0-1~ubuntu.26.04~resolute amd64
docker-ce/resolute 5:29.3.1-1~ubuntu.26.04~resolute amd64

Replace the version string with the exact value from your system, then install Docker Engine and the matching CLI package at that version. Compose and Buildx use the current repository candidates unless you pin those plugin packages separately.

DOCKER_VERSION="5:29.4.1-1~ubuntu.26.04~resolute"
sudo apt install docker-ce="$DOCKER_VERSION" docker-ce-cli="$DOCKER_VERSION" containerd.io docker-buildx-plugin docker-compose-plugin

Alternative Method: Install Docker from Ubuntu’s docker.io Packages

This method uses Ubuntu’s packaged Docker Engine. Compose and Buildx are separate packages in the Ubuntu Universe repository, and the package names differ from Docker’s upstream packages.

Install Docker, Compose, and Buildx from the Ubuntu repositories:

sudo apt install docker.io docker-compose-v2 docker-buildx

If APT cannot locate these packages, enable the Universe repository, then repeat the install command:

sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update

Verify the installed versions:

docker --version
docker compose version
docker buildx version

Expected output from Ubuntu 26.04 packages currently resembles:

Docker version 29.1.3, build 29.1.3-0ubuntu4
Docker Compose version 2.40.3+ds1-0ubuntu1
github.com/docker/buildx 0.30.1 0.30.1-0ubuntu1

Verify Docker on Ubuntu with a Test Container

After either installation method, run the hello-world container to confirm the Docker daemon can pull images and start containers:

sudo docker run --rm hello-world

Successful output looks like:

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/

The Docker daemon socket requires root-level access by default. The next section covers configuring non-root user access so trusted accounts can run Docker without sudo.

Managing Docker with systemd on Ubuntu

Docker installs a daemon service, socket unit, and containerd service, so you can manage the engine with standard systemctl commands. Ubuntu and Docker package builds can place unit files in different systemd directories, so manage them by unit name instead of editing packaged unit paths directly.

sudo systemctl start docker.service

This starts the Docker service immediately for the current session. Use systemctl enable if you want Docker to start automatically at boot.

sudo systemctl stop docker.service

This stops the Docker service until you start it again or reboot. It does not change whether Docker auto-starts on boot.

sudo systemctl restart docker.service

Restarts the Docker service.

sudo systemctl status docker.service

Displays the current status of the Docker service.

sudo systemctl enable docker.service containerd.service

Enables Docker and containerd to start automatically on system boot. Docker installs with this enabled by default, but use this command if you previously disabled auto-start.

sudo systemctl disable docker.service containerd.service

Disables automatic startup for Docker and containerd on system boot. The service remains available for manual start with systemctl start docker.service, but won’t launch during boot.

Configure Docker on Ubuntu After Installation

Manage Docker as a non-root user on Ubuntu

The Docker daemon socket is root-owned by default, and the docker group grants root-equivalent access to that socket. Add only trusted accounts to the group, use a dedicated Ubuntu user when appropriate, or consider rootless mode for tighter isolation.

Create a dedicated Docker management user when you do not want to grant access to your regular account:

sudo useradd -m dockeruser

Verify the new account exists:

id dockeruser
uid=1001(dockeruser) gid=1001(dockeruser) groups=1001(dockeruser)

If the user already exists, skip this step.

To add your current user to the docker group, run:

sudo usermod -aG docker $USER

The Docker group grants root-equivalent privileges to users. Members can access the Docker daemon socket, which provides full control over the host system. Only add trusted users to this group, as they can escape container isolation and modify host files. For production environments, consider using rootless Docker mode or implementing proper access controls.

If you want to grant access to a different account, replace $USER with that username.

After adding a user to the Docker group, you have two options to activate the group membership:

Option 1: Activate immediately without logging out using the newgrp command:

newgrp docker

This starts a new shell session with the docker group active, allowing you to run Docker commands immediately.

Option 2: Log out and back in, or reboot your system for the changes to take effect system-wide.

Verify that the user can run Docker commands:

docker ps

If Docker is working correctly with your user account, you should see an empty container list:

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

This confirms Docker commands run without sudo. If you see a permission error instead, verify the group membership activated correctly or try logging out and back in.

If you encounter permission errors when running Docker commands (such as errors accessing ~/.docker/config.json), fix the ownership and permissions on the Docker configuration directory:

sudo chown "$USER":"$USER" "$HOME/.docker" -R
sudo chmod -R g+rwx "$HOME/.docker"

These commands set the correct ownership and permissions for your user’s Docker configuration directory, resolving common permission-related issues. If you want a refresher on chmod flags, see our chmod command guide.

Configure Docker Log Rotation on Ubuntu

By default, Docker logs to the JSON file format without size limits. This can consume unlimited disk space over time.

Docker’s default json-file logging driver does not limit log file size or implement automatic rotation. Without proper configuration, containers can consume unlimited disk space through logging, potentially filling your filesystem. Always configure log rotation with max-size and max-file options in production environments to prevent disk exhaustion.

To configure log rotation, create the Docker daemon configuration file:

sudo nano /etc/docker/daemon.json

If /etc/docker/daemon.json already exists, merge these log settings with your current JSON instead of replacing the file.

Add the following configuration to limit log file size and count:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}

This configuration limits each container’s log file to 10 megabytes and keeps a maximum of 3 rotated log files. Adjust these values based on your storage capacity and logging requirements.

After creating the file, restart the Docker daemon to apply the changes:

sudo systemctl restart docker.service

Existing containers retain their original logging configuration. Only containers created after this change will use the new log rotation settings.

Basic Docker Commands on Ubuntu After Installation

After Docker is installed, these commands cover the first checks most users run. Replace placeholder container or image IDs with values from your own docker ps or docker images output.

CommandUse
docker infoCheck daemon, storage driver, plugin, and host details.
docker runStart a container from an image.
docker psList running containers; add -a to include stopped containers.
docker imagesList local images and tags.
docker buildBuild an image from a Dockerfile.
docker stopStop a running container by name or ID.
docker rmRemove a stopped container.
docker rmiRemove an image that no container still uses.
docker networkCreate, inspect, or remove Docker networks.
docker volumeCreate, inspect, or remove Docker-managed volumes.

Check daemon details and search Docker Hub before pulling an unfamiliar image:

docker info
docker search ubuntu

Run an interactive Ubuntu container when you want a disposable shell for package tests or command experiments:

docker run -it ubuntu:latest /bin/bash

For image builds, run docker build from the directory that contains your Dockerfile:

docker build -t myimage:latest .

For cleanup, list containers and images first, then stop or remove the specific object you no longer need:

docker ps -a
docker images
docker stop CONTAINER_ID
docker rm CONTAINER_ID
docker rmi IMAGE_ID

Networks and volumes are separate from containers, so create and remove them deliberately when your application needs persistent storage or isolated networking:

docker network create mynetwork
docker volume create myvolume

Save Docker Container Changes as Images

Use docker commit for quick snapshots, not for repeatable production builds. A Dockerfile is easier to review and rebuild, but a commit can be useful while experimenting inside a disposable container.

Start a named container and make your temporary changes inside it:

docker run -it --name mycontainer ubuntu:latest /bin/bash

After exiting the container, save the filesystem changes as a new image tag:

docker commit mycontainer myimage:latest

The snapshot captures filesystem changes inside the container. It does not save Docker networks, named volumes, bind mounts, or runtime flags, so document those separately if you plan to reuse the environment.

Improve Docker Security on Ubuntu

Docker security starts with the host, the daemon socket, and each container’s runtime settings. Use these checks after installation, especially on servers that run internet-facing workloads.

Limit Root-Level Docker Access on Ubuntu

Do not add routine users to the docker group unless they need full control of the Docker daemon. For containers, prefer images designed to run as non-root, or set a user with --user when the application supports it. This reduces the blast radius inside the container, but it does not make an untrusted image safe.

Keep Docker Packages Updated on Ubuntu

Regularly update Docker and the host system to receive security patches and bug fixes. Subscribe to Docker security advisories, then use the upgrade command that matches your package family.

For Docker CE packages from Docker’s repository:

sudo apt update && sudo apt install --only-upgrade docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

For Ubuntu docker.io packages:

sudo apt update && sudo apt install --only-upgrade docker.io docker-compose-v2 docker-buildx

These sequences refresh the package lists and upgrade only the Docker components, leaving the rest of your system untouched.

Consider configuring unattended-upgrades for Ubuntu archive security updates. If Docker came from Docker’s official repository, confirm that unattended-upgrades allows Docker’s repository origin before assuming those third-party packages update automatically; otherwise include the Docker-specific upgrade command in your maintenance routine.

Verify Docker Image Trust and Provenance

Docker’s Content Trust documentation notes ongoing deprecation work, so avoid building new workflows around the older DOCKER_CONTENT_TRUST environment variable without reviewing current Docker guidance. For production images, pin trusted images by digest where practical, use signed release processes and trusted registries, and scan images with Docker Scout or an equivalent tool.

Limit Published Docker Container Ports

Publish only the ports a container actually needs. Bind services to localhost (127.0.0.1) when they do not need LAN or internet access, and use SSH tunneling for private remote administration.

docker run -p 127.0.0.1:8080:80 nginx

This runs an Nginx container with port 80 only accessible from the local machine on port 8080.

Scan Docker Images Before Deployment

Use Docker Scout or third-party scanners to check images for known vulnerabilities before deploying them to production. Rebuild images when base images or application packages receive security updates; scanning an old tag without updating it only confirms the exposure is still present.

Set Docker Container Resource Limits

Prevent a single container from consuming the host by setting memory and CPU limits with flags such as --memory and --cpus. Resource limits are especially important on shared servers, CI runners, and small VPS instances.

Monitor Internet-Facing Docker Containers

For containers that expose SSH, web admin panels, or application login forms, make sure logs are available to host monitoring and alerting. Fail2ban can block repeated attempts when it can read the relevant logs and when the blocking rule matches Docker’s firewall path; test that behavior before relying on it for production traffic.

Troubleshoot Docker on Ubuntu

These fixes cover the most common Docker issues on Ubuntu.

Docker Daemon Is Not Running on Ubuntu

If the Docker daemon is not running, Docker CLI commands report a connection error. Run docker info and look for this server error:

docker info
Client: Docker Engine - Community
 Context:    default
 Debug Mode: false

Server:
failed to connect to the docker API at unix:///var/run/docker.sock; check if the path is correct and if the daemon is running: dial unix /var/run/docker.sock: connect: no such file or directory

Start and enable the Docker service:

sudo systemctl start docker.service
sudo systemctl enable docker.service containerd.service

Verify the fix by re-running the hello-world test container from the earlier verification step.

Permission Denied Connecting to the Docker Socket on Ubuntu

If you run Docker commands without sudo and see a socket permission error, the output looks like:

permission denied while trying to connect to the docker API at unix:///var/run/docker.sock

Check whether your user is in the docker group:

groups $USER
joshua adm dialout cdrom floppy sudo audio dip video plugdev users netdev docker

If docker is missing, add your user to the group and activate it:

sudo usermod -aG docker $USER
newgrp docker

If you prefer not to use newgrp, log out and back in to apply group changes system-wide.

Confirm the socket permissions are owned by root:docker:

ls -l /var/run/docker.sock
srw-rw---- 1 root docker 0 Jan 14 19:56 /var/run/docker.sock

Verify access by listing containers:

docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

APT Cannot Locate Docker or Compose Packages on Ubuntu

If APT reports that docker-ce has no installation candidate, or that docker-compose-plugin cannot be located, first confirm which package family you are using. The official Docker repository provides docker-compose-plugin; Ubuntu’s repositories provide docker-compose-v2 instead.

For the official Docker repository path, verify that the source file exists and points to the expected Ubuntu suite. The grep command keeps the source check focused on the fields that matter:

ls /etc/apt/sources.list.d/docker.sources
grep -E '^(URIs|Suites|Architectures|Signed-By):' /etc/apt/sources.list.d/docker.sources
apt-cache policy docker-ce

Relevant source lines on Ubuntu 26.04 look like this. Ubuntu 24.04 should show Suites: noble, and Ubuntu 22.04 should show Suites: jammy:

URIs: https://download.docker.com/linux/ubuntu
Suites: resolute
Architectures: amd64
Signed-By: /etc/apt/keyrings/docker.asc

If the source file is missing, repeat the official repository setup. If you intentionally chose Ubuntu’s package path, install docker-compose-v2 instead of docker-compose-plugin.

Docker Container Networking Issues on Ubuntu

If containers cannot reach external networks or other containers, verify Docker’s network configuration:

docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
e0f4b42f45f7   bridge    bridge    local
2b92e331d2c7   host      host      local
359d4c681ec9   none      null      local

If the bridge network is missing, restart Docker with sudo systemctl restart docker.service to recreate the default networks. If you use ufw or firewalld, review the firewall warning at the beginning of this guide, as these firewalls may block container traffic by default.

Test container networking by running a simple network test:

docker run --rm busybox ping -c 3 google.com
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
e59838ecfec5: Pulling fs layer
0f4360cf3c3e: Download complete
e59838ecfec5: Download complete
e59838ecfec5: Pull complete
Digest: sha256:2383baad1860bbe9d8a7a843775048fd07d8afe292b94bd876df64a69aae7cb1
Status: Downloaded newer image for busybox:latest
PING google.com (142.250.124.138): 56 data bytes
64 bytes from 142.250.124.138: seq=0 ttl=63 time=38.637 ms
64 bytes from 142.250.124.138: seq=1 ttl=63 time=37.094 ms
64 bytes from 142.250.124.138: seq=2 ttl=63 time=37.385 ms

--- google.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 37.094/37.705/38.637 ms

If this fails, check your host’s DNS configuration and ensure Docker can access /etc/resolv.conf.

Remove Docker from Ubuntu

Use the removal path that matches how you installed Docker.

Remove Official Docker Repository Packages from Ubuntu

Uninstall Docker Engine, the CLI, containerd, and the plugin packages:

sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

Preview unused dependency removal before deleting anything, since APT may list packages unrelated to Docker on reused systems:

sudo apt autoremove --dry-run

If the preview only lists packages you are comfortable removing, run autoremove for real:

sudo apt autoremove

Remove the Docker repository and keyring:

sudo rm -f /etc/apt/sources.list.d/docker.sources
sudo rm -f /etc/apt/sources.list.d/docker.list
sudo rm -f /etc/apt/keyrings/docker.asc
sudo rm -f /usr/share/keyrings/docker.gpg

Refresh the package index:

sudo apt update

Verify the Docker CE packages are gone. No output means these packages are not installed:

dpkg-query -W -f='${binary:Package}\t${db:Status-Status}\n' docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin 2>/dev/null || true
(no output)

Remove Ubuntu docker.io Packages

Uninstall the Ubuntu-packaged engine and plugins:

sudo apt purge docker.io docker-compose-v2 docker-buildx

Preview unused dependency removal before deleting anything:

sudo apt autoremove --dry-run

If the preview only lists packages you are comfortable removing, run autoremove for real:

sudo apt autoremove

Verify the Ubuntu packages are gone. No output means these packages are not installed:

dpkg-query -W -f='${binary:Package}\t${db:Status-Status}\n' docker.io docker-compose-v2 docker-buildx 2>/dev/null || true
(no output)

These commands permanently delete all Docker images, containers, volumes, and custom networks. This action cannot be undone. Back up any important container data before proceeding.

Delete Docker data directories:

sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

Removing /etc/docker deletes daemon configuration files such as daemon.json. Back up any custom settings before deleting this directory.

Remove custom Docker daemon configuration:

sudo rm -rf /etc/docker

Docker Documentation for Ubuntu Users

Use these official Docker resources when you need upstream details that change faster than Ubuntu package guidance:

Docker on Ubuntu Conclusion

Docker should now be installed from the package family that fits your Ubuntu system, with Compose and Buildx ready for image builds and multi-container projects. Keep the docker group limited to trusted users, review exposed ports before publishing containers, and use the matching removal path if you later switch between Docker’s repository and Ubuntu’s docker.io packages.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: