Docker is one of the most popular tools for containerization, allowing developers and system administrators to easily package, distribute, and run applications in isolated environments. It has become an essential tool in modern software development and DevOps workflows. In this guide, we will show you how to install Docker on Linux, specifically focusing on Ubuntu, but we will also touch on the installation process for other distributions.
By the end of this guide, you’ll have Docker installed and ready to use on your Linux machine, and you’ll be familiar with basic commands and troubleshooting tips to ensure everything works smoothly.
What is Docker and Why Should You Use It?
Docker is a platform that allows you to develop, ship, and run applications inside containers. Containers are lightweight and portable environments that include everything needed to run an application: code, runtime, libraries, and dependencies. Docker containers are ideal for deploying applications across different environments (development, testing, and production) because they provide consistency, speed, and isolation.
Why should you use Docker?
- Portability: Docker containers can run on any machine, regardless of the underlying operating system, as long as Docker is installed. Whether you’re running Docker on your local machine, on a cloud server, or in a production environment, your application will run the same way everywhere.
- Efficiency: Docker containers share the host system’s kernel, making them lighter and faster than traditional virtual machines.
- Isolation: Containers isolate applications and their dependencies, ensuring that they do not conflict with other software running on the same machine.
- Scalability: Docker works seamlessly with orchestration tools like Kubernetes to scale applications efficiently.
Docker has become the go-to solution for containerization, and mastering it is an essential skill for developers, system administrators, and DevOps engineers.
Prerequisites Before Install Docker
Before you dive into the installation process, there are a few prerequisites that you need to meet to ensure a smooth installation.
- Linux Distribution Compatibility
Docker supports a variety of Linux distributions, but the installation process can differ slightly based on the distribution you’re using. In this guide, we’ll focus on Ubuntu, but you can also follow similar steps for other distributions like CentOS, Debian, and Fedora. - System Requirements
Docker is lightweight and efficient, but there are some minimum system requirements:- RAM: At least 4GB of RAM is recommended, but Docker can run on systems with as little as 2GB.
- Disk Space: Docker will require some disk space for installation and to store containers, images, and volumes. A minimum of 10GB of free disk space is recommended.
- CPU: Docker runs well on most modern multi-core processors.
- Dependencies
Docker requires certain software packages to be installed. In most cases, these dependencies will be installed automatically, but it’s always good to check.- You will need curl, apt-transport-https, ca-certificates, and software-properties-common installed on your system. These dependencies ensure you can add external repositories and download packages securely.
- Privileges
You need to have root privileges to install Docker. If you are not logged in as the root user, you will need to use sudo for the installation commands. - Linux Kernel Version
Docker requires a 64-bit version of Linux with kernel version 3.10 or higher. Most modern distributions, including Ubuntu 18.04 LTS and later, meet this requirement.

How to Install Docker on Ubuntu?
The installation process for Docker on Ubuntu is relatively simple and can be completed in just a few steps. Let’s get started with the installation process for Ubuntu-based systems.
Step 1: Update Your System
Before installing Docker, it’s always a good idea to update your system to ensure that all existing packages are up-to-date. Open a terminal and run the following commands:
bashCopysudo apt update
sudo apt upgrade
This will update the list of available packages and install the latest versions of any installed software. After the update is complete, you’re ready to install Docker.
Step 2: Install Required Dependencies
Docker requires some dependencies that may not be installed on your system by default. Install these packages by running the following command:
bashCopysudo apt install apt-transport-https ca-certificates curl software-properties-common
These packages will ensure that your system can securely download Docker’s official installation files.
Step 3: Add Docker’s Official GPG Key
Docker packages are signed with a GPG key to ensure their authenticity. To add Docker’s official GPG key, run this command:
bashCopycurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
This will add Docker’s public key to your system, allowing you to securely download and install Docker.
Step 4: Add Docker’s Repository
Next, you need to add Docker’s official APT repository to your system’s list of sources. Run the following command:
bashCopysudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
This command ensures that your system can download the latest stable version of Docker from Docker’s official repository.
Step 5: Install Docker Engine
Now, update your package list to include the new Docker repository and install Docker Engine using the following commands:
bashCopysudo apt update
sudo apt install docker-ce
The docker-ce
package installs the Docker Community Edition, which is the free, open-source version of Docker. Once the installation completes, Docker will be installed and ready to use.
Step 6: Start Docker Service
After the installation is complete, you need to start the Docker service and ensure that it starts automatically on boot. Run the following commands:
bashCopysudo systemctl start docker
sudo systemctl enable docker
These commands will start Docker and configure it to launch automatically whenever your system starts up.
Step 7: Verify Docker Installation
To confirm that Docker has been installed successfully, run the following command to check the Docker version:
bashCopydocker --version
This should output the version of Docker that is installed on your system. If you see the version information, congratulations! Docker is successfully installed.
How to Run Docker Without Sudo?
By default, Docker requires root privileges, which means you must use sudo
before running Docker commands. However, you can add your user to the docker
group to allow running Docker without sudo
.
To add your user to the Docker group, run the following command:
bashCopysudo usermod -aG docker $USER
After running this command, log out and log back in to apply the changes. Now, you should be able to run Docker commands without using sudo
.
How to Install Docker on Linux Distributions?
While this guide focuses on Ubuntu, the installation steps for Docker on other Linux distributions (such as CentOS, Debian, and Fedora) are very similar. Here’s a brief overview of the installation process for some other popular distributions.
Installing Docker on CentOS
- Update your system:bashCopy
sudo yum update
- Install dependencies:bashCopy
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
- Add Docker’s repository:bashCopy
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- Install Docker:bashCopy
sudo yum install docker-ce
- Start Docker:bashCopy
sudo systemctl start docker sudo systemctl enable docker
Installing Docker on Fedora
- Update your system:bashCopy
sudo dnf update
- Install Docker:bashCopy
sudo dnf install docker-ce
- Start Docker:bashCopy
sudo systemctl start docker sudo systemctl enable docker
Troubleshooting Docker Installation Issues
While Docker installation is generally smooth, there are a few common issues you may encounter. Let’s address some of these:
- Docker Daemon Not Running
If you receive an error stating that the Docker daemon isn’t running, try restarting the Docker service with the following command:bashCopysudo systemctl restart docker
- Permissions Issues
If you encounter permission errors when running Docker commands, ensure that your user is part of thedocker
group. You can add your user to the Docker group by running:bashCopysudo usermod -aG docker $USER
After this, log out and log back in. - Network Issues
Docker may sometimes encounter network connectivity issues when pulling images or accessing the internet. You can restart the Docker service and check your firewall settings if this happens.
Conclusion
Install Docker on Linux is a straightforward process that provides you with a powerful tool for containerizing your applications. By following the steps outlined in this guide, you should have Docker installed and running on your Ubuntu (or other Linux distributions) system.
Docker is a game-changer for developers and system administrators, offering a lightweight and consistent way to deploy and manage applications. With Docker installed, you can start creating containers, testing applications, and deploying software across various environments with ease.