Docker has become one of the most popular tools for developers and DevOps engineers. It makes it super easy to package applications and run them in isolated environments called containers. If you’re using Ubuntu 22.04, installing Docker is straightforward—but instead of using the older version from Ubuntu’s repositories, it’s better to install the latest version directly from Docker’s official source.
In this guide, I’ll show you how to install the latest Docker CE (Community Edition) on Ubuntu 22.04 step by step.
Step 1: Update Your System
First, update your system to make sure everything is up to date:
sudo apt update && sudo apt upgrade -y
Step 2: Uninstall Old Versions (Optional)
If you installed Docker before, remove the old packages to avoid conflicts:
sudo apt remove docker docker-engine docker.io containerd runc
Step 3: Install Required Dependencies
We need a few packages so Ubuntu can use repositories over HTTPS:
sudo apt install ca-certificates curl gnupg lsb-release -y
Step 4: Add Docker’s Official GPG Key
Now, add Docker’s official GPG key to your system:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Step 5: Set Up the Docker Repository
Next, add the Docker repository to your sources list:
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
Step 6: Install Docker Engine
Update your package index and install Docker:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
Step 7: Verify the Installation
Check that Docker is running:
sudo systemctl status docker
Run a quick test:
sudo docker run hello-world
If everything is set up correctly, you’ll see a message confirming Docker is working.
Step 8: Run Docker Without sudo
(Optional)
By default, you need sudo
to run Docker. To run it as a normal user:
sudo usermod -aG docker $USER
Then log out and back in for the changes to apply.
Conclusion
That’s it—you’ve successfully installed the latest Docker on Ubuntu 22.04. With Docker up and running, you can start pulling images, creating containers, and building your own applications inside lightweight environments.
Whether you’re experimenting with microservices or deploying a full production stack, Docker makes your life much easier.