Installing Docker on Ubuntu - The Complete Guide

Installing Docker on Ubuntu

Get Docker running in under 5 minutes

📅 October 21, 2025 | ⏱️ 4 min read | 🏷️ Docker, Ubuntu, DevOps

So you need Docker on your Ubuntu machine. Maybe you're containerizing an app, setting up a dev environment, or just want to see what all the hype is about. Either way, let's get it installed.

This guide walks you through installing Docker CE (Community Edition) from the official Docker repository. We're not using the Ubuntu default repo because the official one usually has newer versions.

What You Need

  • Ubuntu (18.04 or later)
  • Sudo access
  • 5 minutes of your time

The Installation

Step 1: Update Your System

First, let's make sure everything is up to date:

sudo apt update -y

Step 2: Install Required Packages

Docker needs a few dependencies to work properly. Let's grab them:

sudo apt install apt-transport-https ca-certificates curl software-properties-common -y

These packages let your system download stuff securely over HTTPS and manage software repositories.

Step 3: Add Docker's GPG Key

This verifies that the packages you download are actually from Docker:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Step 4: Add Docker Repository

Now we tell Ubuntu where to find Docker:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" -y

This adds the official Docker repo to your system's sources list.

Step 5: Update Package Database

Refresh the package list to include Docker:

sudo apt update -y

Step 6: Check Available Version (Optional)

Want to see what version you're about to install?

apt-cache policy docker-ce

This shows you available Docker versions. You can skip this if you don't care about the specifics.

Step 7: Install Docker

Here's the main event:

sudo apt install docker-ce -y

This installs Docker CE. It'll take a minute or two depending on your connection.

Step 8: Run Docker Without Sudo

By default, you need sudo for Docker commands. Let's fix that:

sudo usermod -aG docker $USER && newgrp docker

This adds your user to the docker group and activates it immediately. No more typing sudo every time.

Verify It Works

Let's make sure everything installed correctly:

docker --version

You should see something like:

Docker version 24.x.x, build xxxxxxx

Now try running a test container:

docker run hello-world

If you see "Hello from Docker!" with a bunch of info, you're all set. Docker is running.

All Commands Together

Here's everything in one copy-paste block:

sudo apt update -y sudo apt install apt-transport-https ca-certificates curl software-properties-common -y curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" -y sudo apt update -y sudo apt install docker-ce -y sudo usermod -aG docker $USER && newgrp docker

Quick tip: If the newgrp docker command doesn't work right away, just log out and log back in. That'll do the trick.

What's Next?

Now that Docker is running, you can start containerizing apps. Try pulling some images from Docker Hub, running containers, or setting up Docker Compose for multi-container setups.

That's it. Docker is installed and ready to go. Happy containerizing! 🐳

Written by someone who installs Docker more often than they'd like to admit | 2025

Comments

Popular posts from this blog