---
title: "How To Install Docker On Linux In 4 Easy Steps"
description: "A step-by-step guide to installing Docker on Linux in 4 steps, from updating the package index to running your first Docker container."
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/blog/post/how-to-install-docker-on-linux-in-4-easy-steps
---

# How To Install Docker On Linux In 4 Easy Steps

## Introduction

Docker is a platform that lets developers create, deploy, and run applications in containers. Containers are isolated environments that allow you to run your applications in a consistent and reproducible way, no matter what platform or environment you're using. With Docker, you can easily move your applications from one platform to another, making it a popular choice for developers and DevOps teams alike.

Whether you're building a new application or need to modernize an existing one, Docker provides a simple and efficient way to manage your applications and infrastructure. Here's how to install Docker on Linux in 4 steps. By the end, you'll have Docker running and ready to use.

## Prerequisites

Before you can install Docker on Linux, there are a few prerequisites you need to be aware of. First, you need to have a Linux machine that meets the minimum system requirements for running Docker. Docker requires a 64-bit operating system and a version of the Linux kernel that is 3.10 or later. You can check your Linux version by running the following command in your terminal:

```shell
# check your Linux version
uname -r
```

Additionally, you'll need to have the appropriate permissions to install software on your Linux machine. If you're logged in as a regular user, you may need to use `sudo` to install Docker.

Another important consideration is the type of Linux distribution you're using. Docker provides native packages for several popular Linux distributions, including Debian, Ubuntu, Fedora, and CentOS. You'll want to make sure you're using one of these supported distributions before you start the installation process.

Once you've confirmed that your Linux machine meets the prerequisites, you're ready to move on to the next step and start installing Docker.

## Installing Docker

### Step 1: Update the package index

The first step in installing Docker on Linux is to update the package index. That way you get the most recent version of the Docker packages available, and you avoid a few compatibility problems.

Here's how to update the package index on different types of Linux systems:

- Arch-based Linux systems:

```shell
# update the package index
sudo pacman -Syy
```

- Debian-based Linux systems:

```shell
# Add Docker's official GPG key:
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

# Add the 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 "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# update the package index
sudo apt-get update
```

- Red Hat-based Linux systems:

```shell
# update the package index
sudo yum update
```

- Suse-based Linux systems:

```shell
# update the package index
sudo zypper refresh
```

- Fedora-based Linux systems:

```shell
# update the package index
sudo dnf update
```

Once the package index has been updated, you're ready to install the Docker packages themselves. It's a good practice to periodically update your package index, so make sure to check for updates frequently to keep your system up-to-date.

### Step 2: Installing Docker on Linux using the package manager

With the package index updated, it's time to install Docker on your Linux machine. This is done using the package manager for your Linux distribution.

Here's how to install Docker on different types of Linux systems:

- Arch-based Linux systems:

```shell
# install Docker
sudo pacman -S docker
```

- Debian-based Linux systems:

```shell
# install Docker
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

- Red Hat-based Linux systems:

```shell
# install Docker
sudo yum install docker
```

- Suse-based Linux systems:

```shell
# install Docker
sudo zypper install docker
```

- Fedora-based Linux systems:

```shell
# install Docker
sudo dnf install docker
```

Once the installation is complete, you can start using Docker on your Linux machine. However, there are a few more steps you need to take before you can start using Docker.

Specifically, you need to start the Docker service and enable it to start automatically on boot. That way Docker is always running and ready to use. Here's how to start the Docker service and enable it to start automatically on boot:

```shell
# start the Docker service
sudo systemctl start docker

# enable the Docker service to start automatically on boot
sudo systemctl enable docker
```

### Step 3: Verifying the Docker installation

Now that Docker is installed and running on your Linux machine, it's time to verify that the installation was successful. The best way to do this is to run a simple Docker command and see if it returns the expected output.

One of the simplest Docker commands you can run is the `docker info` command. This command displays system-wide information about your Docker installation, including the number of containers and images, the version of Docker you're running, and more.

To run the `docker info` command, open a terminal window and type:

```shell
# run the docker info command
docker info
```

If the installation was successful, you should see a lot of information about your Docker installation, similar to the following:

```shell title="Output"
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 19.03.13
Storage Driver: overlay2
 Operating System: Fedora 33 (Twenty Three)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.792GiB
 Name: localhost.localdomain
 ID: <id>
...
```

This confirms that Docker is installed and running on your Linux machine. If you encounter any errors, you may need to check the logs or consult the Docker documentation for further guidance.

With Docker installed and working correctly, you're ready to start creating and managing your containers. In the next step, you'll learn how to use Docker to run your first container.

As a security measure, Docker runs as a non-root user by default. This means that you need to add your user to the `docker` group to be able to run Docker commands. You can do this by running the following command:

```shell
# add your user to the docker group
sudo usermod -aG docker $USER
```

### Step 4: Running your first Docker container

With Docker installed and verified on your Linux machine, it's time to start using it to run containers. The easiest way to get started with Docker is to run a simple container, such as a "Hello World" container.

To run your first Docker container, you'll need to use the `docker run` command. This command takes a Docker image and creates a new container from that image, running the commands specified in the image's definition.

Here's an example of how to run a "Hello World" container:

```shell
docker run hello-world
```

This command tells Docker to run the `hello-world` image. If you don't have the `hello-world` image on your system, Docker will automatically download it from the Docker Hub, which is a repository of Docker images.

Once the container is running, you should see some output similar to the following:

```shell
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
```

This confirms that your first Docker container is up and running. You can use the `docker ps` command to see a list of all the containers currently running on your system:

```shell
docker ps
```

With your first Docker container running, you can use Docker to run any type of application, from simple single-container applications to complex multi-container applications.

## Conclusion

This article covered how to install Docker on Linux in 4 steps. Docker's containerization technology makes it easy to run and manage applications on a variety of platforms, including Linux.

Following these steps, you can install Docker on your Linux machine, verify the installation, and run your first container. From there, you can use Docker to run and manage a wide range of applications and services.

Whether you're a software developer, system administrator, or DevOps engineer, Docker can improve the efficiency and reliability of your application deployment and management processes.

## References

1.  [Install Docker Engine - Official Docker Documentation](https://docs.docker.com/engine/install/)
2.  [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/)
3.  [Install Docker Engine on Debian](https://docs.docker.com/engine/install/debian/)
4.  [Install Docker Engine on Fedora](https://docs.docker.com/engine/install/fedora/)
5.  [Install Docker Engine on CentOS](https://docs.docker.com/engine/install/centos/)
6.  [Install Docker Engine on Arch Linux (Community Supported)](https://wiki.archlinux.org/title/Docker)
7.  [Post-installation steps for Linux - Docker Documentation](https://docs.docker.com/engine/install/linux-postinstall/) (Covers managing Docker as a non-root user)
8.  [Docker Hub - Official Image Repository](https://hub.docker.com/)
9.  `docker run` command reference - [Docker Documentation](https://docs.docker.com/engine/reference/commandline/run/)
10. `docker info` command reference - [Docker Documentation](https://docs.docker.com/engine/reference/commandline/info/)
11. `docker ps` command reference - [Docker Documentation](https://docs.docker.com/engine/reference/commandline/ps/)
12. "What is a Container?" - Docker Documentation, [https://www.docker.com/resources/what-container/](https://www.docker.com/resources/what-container/)
13. "Get Started with Docker" - Docker Documentation, [https://docs.docker.com/get-started/](https://docs.docker.com/get-started/)
14. Linux `uname` command - (Example: man page or tutorial.), [https://man7.org/linux/man-pages/man1/uname.1.html](https://man7.org/linux/man-pages/man1/uname.1.html)
15. Linux `systemctl` command - (Example: man page or tutorial.), [https://man7.org/linux/man-pages/man1/systemctl.1.html](https://man7.org/linux/man-pages/man1/systemctl.1.html)
