Docker has simplified SDLC by introducing a new way of deploying applications and their dependencies within a few minutes. We know that Docker creates isolated spaces called containers and encapsulates the application within them, which allows us to deal with microservices architecture too. Docker is available on most platforms including Ubuntu, a mostly used Linux distribution.
In this blog, we will discover how to Install Docker on Ubuntu.
Table of Contents
What is Docker?
Docker is an open-source containerization platform that simplifies the sharing, deployment, and maintenance of application code by allowing developers to convert the code into an image called a Docker image and then run these images within the isolated spaces created by Docker called containers. Since you are here to install Docker on Ubuntu, we assume you are already aware of the Docker tool, its features, functionalities, architecture, components, advantages, and other related terminologies.
System Requirements for Installing Docker on Ubuntu (24.10/ 24.04/ 22.04/ 20.04)
Installing Docker on Ubuntu is straightforward and can be done on various Ubuntu versions. Below are the requirements:
Operating System Requirements
Any of the below versions will work for you.
- Ubuntu 24.10 (Oracular )
- Ubuntu 24.04 (Noble LTS)
- Ubuntu 22.04 (Jammy LTS)
- Ubuntu20.04 ( Focal LTS)
Docker is compatible with architectures like x86_64/amd64, armhf, arm64, s390x, and ppc64le.
Uninstall any old Versions of Docker installed
Most Linux distributions, including Ubuntu, provide unofficial Docker packages by default. These can be installed quickly but may cause conflicts with the official package. Therefore, it is recommended to uninstall any existing Docker versions first.
A few of the unofficial packages available are docker.io, docker-compose, docker-compose-v2, docker-doc, and podman-docker.
To remove unofficial Docker packages, use the command:
$for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
Installing Docker on Ubuntu
Installing Docker on Ubuntu is a simple and easy process where you just need to run new commands in order. You can install Docker Engine directly using the APT repository or using the Docker Desktop. Just access the terminal or your environment and start running the below commands.
Lead the DevOps Industry with Confidence
Enroll in Our DevOps Course
Method 1: Installing Docker Engine Using APT repository
1. We will update the current packages available in your machine and install additional required packages and a GPG key to ensure that we have downloaded the correct and official Docker package.
sudo apt-get update
sudo apt-get install ca-certificates curl
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
2. Add Docker repository to APT sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
3. Install Docker Engine:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
4 Install a Specific Docker Package Version:
If you are planning to install Docker on a specific package of Ubuntu, you need to list the the available versions in the repository and then install the desired version.
apt-cache madison docker-ce | awk '{ print $3 }'
As a response of the above command, you will be displayed a version available in your environment, you need to select and run it.
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
5. Verify Docker Installation:
In order to check if you were successfully able to install Docker or not, you can try running hello-world image by running sudo docker run hello-world.
sudo docker run hello-world
This will download a test image and run it in a container. If the container runs, it will print a confirmation message and exit.
Method 2: Install Docker Engine from a Package on Ubuntu
1. Download Docker Packages:
- Go to: Docker Ubuntu Packages
- Select your Ubuntu version, pool/stable/ and then choose architecture (amd64, armhf, arm64, s390x).
- Download:
- containerd.io__.deb
- docker-ce__.deb
- docker-ce-cli__.deb
- docker-buildx-plugin__.deb
- docker-compose-plugin__.deb
2. Install Docker Packages:
sudo dpkg -i ./containerd.io__.deb \
./docker-ce__.deb \
./docker-ce-cli__.deb \
./docker-buildx-plugin__.deb \
./docker-compose-plugin__.deb
3. Start Docker and Verify Installation:
sudo service docker start
sudo docker run hello-world
If the installation is successful, Docker will be properly installed and operational on your system.
Installing Docker Desktop on Ubuntu
Docker Desktop is another way to install Docker Engine on Linux with Graphical User Interface. The process of configuring Docker remains the same.
- Setup a Docker package repository.
- You need to download the latest DEB package and then install it using the below commands:
sudo apt-get update
sudo apt-get install ./docker-desktop-amd64.deb
Once installed, you can try launching the application by simply double-clicking on it.
Upgrade Docker Desktop
When a new version of Docker Desktop is available, the Docker user interface will display a notification. You must download the new package whenever you wish to upgrade Docker Desktop and execute it.
The following command will help you update your Docker Desktop to the newest version.
sudo apt-get install ./docker-desktop-amd64.deb
Working with Docker Containers, Images, Dockerfile, and Commands
Once you have installed Docker successfully, you can start using Docker commands to achieve your tasks. Let’s run a few of the popular docker commands:
1. Docker Run Command
This command helps you run a test container
docker run hello-world
2. Pulling an Image from a Docker Registry
This command will help you to download a public image in your system.
docker pull mysql:5.5.45
3. Listing Images
It lists all Docker images present in your system.
docker images
4. Creating a Container using a specific image
docker run -it -d –name container_name image_name
5. Listing All Containers
This will help you to list all containers.
docker ps -a
Master Essential DevOps Concepts at No Cost
Take Advantage of Our Free DevOps Course
6. Running container on specific port number
docker run -it -d –name container_name -p 81:80 image_name
7. Executing a Container
If you want to go inside the container to make any changes in the container environment, you can use the below command.
docker exec -it container_name bash
8. Committing Changes in a Container to a Docker Image
docker commit -m container_id container_id repository/new_image_name
9. Removing Images
docker rmi image_name
10. Stopping Docker Container
docker stop container_name
11. Removing Docker Container
docker rm container_name
Creating and Building a Dockerfile
1. Create a Dockerfile:
nano Dockerfile
2. Example Dockerfile for Apache Server:
FROM ubuntu
RUN apt-get update
RUN apt-get install -y apache2
ENTRYPOINT apachectl -D FOREGROUND
Build an image from the Dockerfile:
docker build . -t new_image_name
Push Docker images to Docker Hub:
docker login
docker push repository/new_image_name
In order to learn more commands, you can follow the Docker commands guide.
Get 100% Hike!
Master Most in Demand Skills Now!
Conclusion
This comprehensive guide covers the essential aspects of installing Docker on Ubuntu. Docker is a powerful containerization platform that offers numerous benefits for developers and system administrators, including improved security, portability, resource efficiency, and reproducibility. Understanding the concept of Docker and verifying system requirements is crucial before starting the installation process. Following the step-by-step instructions in this guide, you can successfully install Docker on your Ubuntu system and leverage its capabilities.
If you are looking to learn tools like Docker, enroll in our top DevOps course.
How To Install Docker on Ubuntu – FAQs
How to Install Docker on Windows?
Installing Docker on Windows is as simple as installing Docker on Ubuntu. We recommend you visit the correct Docker installation guide.
How Do I Know Docker is Installed on Ubuntu?
You can verify by pulling a docker test image or running the command docker –version.
How to Start Docker in Ubuntu Terminal?
To start Docker, use the command:
sudo systemctl start docker
What is Docker Used For?
Docker is used for automating the deployment and management of applications in lightweight, portable, isolated space containers.
How to Stop Docker?
Run sudo systemctl stop docker command to stop Docker.
Break it down step by step with this informative video.
Our Devops Courses Duration and Fees
Cohort Starts on: 17th May 2025
₹22,743
Cohort Starts on: 10th May 2025
₹22,743
Cohort Starts on: 26th Apr 2025
₹22,743