
How to Install Docker on Ubuntu (Beginner-Friendly Guide with Command Explanations)
Docker is a powerful tool that allows you to run applications in containers — lightweight, portable, and consistent environments that make development and deployment faster and more efficient. If you’re new to Docker or Linux, this guide is for you.
Let’s get Docker installed on your Ubuntu server step by step, with every command explained so you actually understand what’s happening under the hood.
How to Setup a Cloud VPS with MaxReseller (Step-by-Step Guide)
🧑💻 Step 1: Log In to Your Ubuntu Server
Open PowerShell (on Windows) or Terminal (on Mac/Linux), and connect to your server:
-
ssh
: Secure Shell, used to connect remotely. -
root@your_ip
: Replaceyour_ip
with your actual server IP address. You’ll be logging in as the root user. -
You’ll be asked to enter the root password.
✅ Once you’re in, you’re ready to start installing Docker.
🧰 Step 2: Update Your Package Index
Before installing anything, update your system so it knows about the latest available software versions:
-
sudo
: Executes the command with administrator privileges. -
apt-get update
: Downloads the package lists from repositories and updates your local cache. This ensures you’re installing the latest versions of packages.
🔧 Step 3: Install Required Dependencies
Docker needs some essential tools to be installed first:
-
ca-certificates
: Keeps your system up-to-date with trusted Certificate Authorities. Needed for secure (HTTPS) connections. -
curl
: A command-line tool to download files from URLs — we’ll use it to grab Docker’s GPG key.
🔐 Step 4: Add Docker’s Official GPG Key
Docker signs their packages to ensure authenticity. To verify those packages, you need Docker’s GPG key:
-
Creates a directory (
/etc/apt/keyrings
) to securely store GPG keys with correct permissions.
-
Downloads Docker’s GPG key and saves it.
-
Gives read access to all users for the GPG key file. This is required so APT can verify Docker’s packages.
📦 Step 5: Add Docker’s Repository
Now we tell Ubuntu where to look for official Docker packages:
-
This command adds Docker’s repository to the list of software sources (
/etc/apt/sources.list.d/docker.list
). -
It includes architecture detection and uses the signed key you just downloaded.
🔁 Step 6: Update Again (Now With Docker Repo)
Now your system knows where to find Docker and its latest versions.
🐳 Step 7: Install Docker Engine and Tools
Here’s what each package does:
-
docker-ce
: The main Docker engine (Community Edition). -
docker-ce-cli
: Command Line Interface to interact with Docker. -
containerd.io
: The core container runtime behind Docker. -
docker-buildx-plugin
: Extended build support for Docker (multi-architecture builds, etc.). -
docker-compose-plugin
: Lets you manage multi-container apps withdocker compose
command.
✅ Step 8: Verify Docker is Installed
That’s it — Docker is installed and ready to go!