Simple Steps to Install Docker on Ubuntu
Introduction:
Docker is a powerful tool that lets you package and run applications in lightweight, portable containers.
Instead of installing software directly on your system, Docker lets you run everything in isolated environments—so it’s cleaner, faster, and works the same on any machine. Whether you’re building apps, testing code, or deploying to production, Docker simplifies the process and saves you tons of setup time.
PREREQUISITES:
- If you’re using a firewall tool like UFW or firewalld, keep in mind that Docker can bypass your firewall rules when exposing container ports.
- Also, Docker only works with iptables, not nftables. So, make sure your firewall rules are created using
iptables
orip6tables
, and add them to theDOCKER-USER
chain to control traffic properly.
Ubuntu Versions for Docker Engine:
To install Docker Engine, you’ll need a 64-bit version of one of the following Ubuntu releases:
- Ubuntu 24.10 (Oracular)
- Ubuntu 24.04 LTS (Noble)
- Ubuntu 22.04 LTS (Jammy)
- Ubuntu 20.04 LTS (Focal)
Docker supports multiple system architectures, including:
- x86_64 / amd64 (most common)
- arm64
- armhf
- s390x
- ppc64le (ppc64el)
Make sure your system matches one of these versions and architectures before proceeding with the installation.
Installation Method For Docker:
Update Your System
Ensure your system packages are up to date before installing Docker.
sudo apt update
sudo apt upgrade -y
Install Required Dependencies
Install tools needed to work with external repositories over HTTPS.
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
Add Docker’s Official GPG Key
Add Docker’s secure key to verify packages from their repository.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Set Up Docker Repository
Add the Docker repository to your system’s software sources.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Refresh Your Package List
Update your system again to include Docker’s packages.
sudo apt update
Install Docker Engine
Install the Docker runtime and command-line tools.
sudo apt install docker-ce docker-ce-cli containerd.io -y
Check Docker Version
Verify that Docker was installed successfully.
sudo docker --version
Run a Test Container
Make sure Docker is working by running the Hello World image.
docker run hello-world
Conclusion:
Starting with Docker might feel like learning a new language at first, but once you get the basics, it becomes an incredibly powerful tool in your development toolkit.
By mastering containers, you’re stepping into a world where applications are more portable, scalable, and reliable than ever before.