How to Install Docker on Ubuntu

Docker is a powerful containerization tool that makes it easy to run applications in isolated environments. If you’re using Ubuntu and want to get Docker installed, this guide will walk you through the process step by step.

System Requirements

Before we start, make sure your system meets these requirements:

  • Ubuntu Version: You need one of these 64-bit Ubuntu versions:
    • Ubuntu 24.10 (Oracular)
    • Ubuntu 24.04 LTS (Noble)
    • Ubuntu 22.04 LTS (Jammy)
  • Architecture: Compatible with x86_64 (amd64), armhf, arm64, s390x, and ppc64le
  • Sudo privileges: You’ll need administrative access

Important Security Note

Firewall Warning: If you use ufw or firewalld for firewall management, be aware that Docker can bypass your firewall rules when exposing container ports. Docker only works with iptables-nft and iptables-legacy, not with nft rules.

Step 1: Remove Old Docker Versions

First, let’s clean up any existing Docker installations that might conflict:

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done

Don’t worry if the system reports that some packages aren’t installed – that’s normal.

Step 2: Update Your System

Make sure your package list is up to date:

sudo apt-get update

Step 3: Install Required Packages

Install the packages needed for the Docker installation:

sudo apt-get install ca-certificates curl

Step 4: Add Docker’s Official GPG Key

Create a directory for Docker’s key and download it:

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

Step 5: Add Docker Repository

Add Docker’s official repository to your system:

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

Update your package list again:

sudo apt-get update

Step 6: Install Docker

Now install Docker and all its components:

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

Step 7: Verify Installation

Test that Docker is working correctly:

sudo docker run hello-world

If successful, you’ll see a welcome message confirming Docker is running properly!

Important Notes

Ubuntu Derivatives: This guide is specifically for official Ubuntu versions. While it might work on Ubuntu derivatives like Linux Mint, it’s not officially supported.

Data Preservation: When you uninstall Docker, your images, containers, volumes, and networks in /var/lib/docker/ are kept. If you want a completely clean installation, you’ll need to remove this directory manually.

Running Without Sudo: Initially, you need sudo for Docker commands. To run Docker without sudo, you can add your user to the docker group (we’ll cover this in a future post).

What’s Installed

Your Docker installation includes:

  • docker-ce: Docker Community Edition engine
  • docker-ce-cli: Command line interface
  • containerd.io: Container runtime
  • docker-buildx-plugin: Advanced build features
  • docker-compose-plugin: Multi-container application management

Next Steps

Now that Docker is installed on your Ubuntu system, you can:

  • Start running containers
  • Build your own Docker images
  • Set up development environments
  • Explore Docker Compose for complex applications

Troubleshooting

If you encounter issues:

  1. Make sure you’re using a supported Ubuntu version
  2. Verify you have sudo privileges
  3. Check your internet connection
  4. Try running each command individually
  5. Make sure your system is fully updated

Docker is now ready to use on your Ubuntu system! Stay tuned for more Docker tutorials and tips.


Need help with your Docker installation? Drop a comment below and we’ll assist you!

Loading

Über chukfinley

I am a long time Linux user and FLOSS enthusiast. I use Debian with DWM. Furthermore, I know how to code in Python, Flutter, HTML (How to meet ladies). I also love minimalism.

Zeige alle Beiträge von chukfinley →

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert