---
title: "How To Install Docker On Linux In 4 Easy Steps"
lang: "en"
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/post/how-to-install-docker-on-linux-in-4-easy-steps
---

![Blog post image for How To Install Docker On Linux In 4 Easy Steps - A step-by-step guide to installing Docker on Linux in 4 steps, from updating the package index to running your first Docker container.](/_astro/hero.CpX7CDI1_Z1Y9iFl.webp)

[Home](/)›[Blog](/blog)›[All Categories](/blog/categories)›[Docker](/blog/categories/docker)

Blog

[Prev in DockerGet Started with Building ReactJS and Docker: A Complete Guide](/blog/post/get-started-with-building-reactjs-and-docker-a-complete-guide)[Next in DockerHow to Run an Apache Web Server Using Docker on an AWS EC2 Instance](/blog/post/how-to-run-an-apache-web-server-using-docker-on-an-aws-ec2-instance)

[Docker](/blog/categories/docker)[Linux](/blog/categories/linux)[DevOps](/blog/categories/devops)[System Administration](/blog/categories/system-administration)[Containerization](/blog/categories/containerization)

# How To Install Docker On Linux In 4 Easy Steps

[Mohammad Abu Mattar](/authors/mohammad-abu-mattar)Published: 12 Feb 202305 Mins read08 Mins listen

[Markdown for AI(opens in a new tab)](/post/how-to-install-docker-on-linux-in-4-easy-steps/index.md "Open the plain-Markdown version of this page, for pasting into an AI tool")

TL;DR

A step-by-step guide to installing Docker on Linux in 4 steps, from updating the package index to running your first Docker container.

Series

[Docker Essentials](/series/docker-essentials)1/3

[NextHow To Run MySQL in a Docker Container: A Step-by-Step Guide with Customization Tips](/blog/post/how-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips)

All posts in this series (3)

Blog3

1.  [How To Install Docker On Linux In 4 Easy StepsYou are here](/blog/post/how-to-install-docker-on-linux-in-4-easy-steps)
2.  [How To Run MySQL in a Docker Container: A Step-by-Step Guide with Customization Tips](/blog/post/how-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips)
3.  [Get Started with Building ReactJS and Docker: A Complete Guide](/blog/post/get-started-with-building-reactjs-and-docker-a-complete-guide)

### How To Install Docker On Linux In 4 Easy Steps

Contents

[Introduction](#introduction)[Prerequisites](#prerequisites)[Installing Docker](#installing-docker)[Step 1: Update the package index](#step-1-update-the-package-index)[Step 2: Installing Docker on Linux using the package manager](#step-2-installing-docker-on-linux-using-the-package-manager)[Step 3: Verifying the Docker installation](#step-3-verifying-the-docker-installation)[Step 4: Running your first Docker container](#step-4-running-your-first-docker-container)[Conclusion](#conclusion)[References](#references)

## [Introduction](#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](#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:

Terminal window

```
1# check your Linux version2uname -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](#installing-docker)

### [Step 1: Update the package index](#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:

Terminal window

```
1# update the package index2sudo pacman -Syy
```

-   Debian-based Linux systems:

Terminal window

```
1# Add Docker's official GPG key:2sudo apt-get update3sudo apt-get install ca-certificates curl4sudo install -m 0755 -d /etc/apt/keyrings5sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc6sudo chmod a+r /etc/apt/keyrings/docker.asc7
8# Add the repository to Apt sources:9echo \10  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \11  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \12  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null13# update the package index14sudo apt-get update
```

-   Red Hat-based Linux systems:

Terminal window

```
1# update the package index2sudo yum update
```

-   Suse-based Linux systems:

Terminal window

```
1# update the package index2sudo zypper refresh
```

-   Fedora-based Linux systems:

Terminal window

```
1# update the package index2sudo 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](#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:

Terminal window

```
1# install Docker2sudo pacman -S docker
```

-   Debian-based Linux systems:

Terminal window

```
1# install Docker2sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

-   Red Hat-based Linux systems:

Terminal window

```
1# install Docker2sudo yum install docker
```

-   Suse-based Linux systems:

Terminal window

```
1# install Docker2sudo zypper install docker
```

-   Fedora-based Linux systems:

Terminal window

```
1# install Docker2sudo 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:

Terminal window

```
1# start the Docker service2sudo systemctl start docker3
4# enable the Docker service to start automatically on boot5sudo systemctl enable docker
```

### [Step 3: Verifying the Docker installation](#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:

Terminal window

```
1# run the docker info command2docker info
```

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

Output

```
1Containers: 02 Running: 03 Paused: 04 Stopped: 05Images: 06Server Version: 19.03.137Storage Driver: overlay28 Operating System: Fedora 33 (Twenty Three)9 OSType: linux10 Architecture: x86_6411 CPUs: 212 Total Memory: 7.792GiB13 Name: localhost.localdomain14 ID: <id>15...
```

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:

Terminal window

```
1# add your user to the docker group2sudo usermod -aG docker $USER
```

### [Step 4: Running your first Docker container](#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:

Terminal window

```
1docker 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:

Terminal window

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

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:

Terminal window

```
1docker 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](#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](#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)

Was this useful?

## Tags

[#Docker Installation](/blog/tags/docker-installation)[#Linux Setup](/blog/tags/linux-setup)[#DevOps Tools](/blog/tags/devops-tools)[#Container Technology](/blog/tags/container-technology)[#Package Management](/blog/tags/package-management)[#Linux Distributions](/blog/tags/linux-distributions)

## Share

[Facebook](https://facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-docker-on-linux-in-4-easy-steps "Share on Facebook")[Twitter](https://twitter.com/intent/tweet/?text=How%20To%20Install%20Docker%20On%20Linux%20In%204%20Easy%20Steps&url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-docker-on-linux-in-4-easy-steps "Share on Twitter")[LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-docker-on-linux-in-4-easy-steps&title=How%20To%20Install%20Docker%20On%20Linux%20In%204%20Easy%20Steps&summary=A%20step-by-step%20guide%20to%20installing%20Docker%20on%20Linux%20in%204%20steps%2C%20from%20updating%20the%20package%20index%20to%20running%20your%20first%20Docker%20container.&source=https://mkabumattar.com "Share on LinkedIn")[WhatsApp](https://wa.me/?text=How%20To%20Install%20Docker%20On%20Linux%20In%204%20Easy%20Steps%20https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-docker-on-linux-in-4-easy-steps "Share on WhatsApp")[Telegram](https://t.me/share/url?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-docker-on-linux-in-4-easy-steps&text=How%20To%20Install%20Docker%20On%20Linux%20In%204%20Easy%20Steps "Share on Telegram")[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-docker-on-linux-in-4-easy-steps&title=How%20To%20Install%20Docker%20On%20Linux%20In%204%20Easy%20Steps "Share on Reddit")[Hacker News](http://news.ycombinator.com/submitlink?u=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-docker-on-linux-in-4-easy-steps&t=How%20To%20Install%20Docker%20On%20Linux%20In%204%20Easy%20Steps "Share on Hacker News")[Pinterest](https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-docker-on-linux-in-4-easy-steps&media=&description=A%20step-by-step%20guide%20to%20installing%20Docker%20on%20Linux%20in%204%20steps%2C%20from%20updating%20the%20package%20index%20to%20running%20your%20first%20Docker%20container. "Share on Pinterest")[Email](<mailto:?subject=How%20To%20Install%20Docker%20On%20Linux%20In%204%20Easy%20Steps&body=Check out this article: https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-docker-on-linux-in-4-easy-steps>)

## Comments

## You might also enjoy

More posts on similar topics

[![How To Run MySQL in a Docker Container: A Step-by-Step Guide with Customization Tips](/_astro/hero.W_-sxnO__2i0INW.webp)](/blog/post/how-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips)

## [How To Run MySQL in a Docker Container: A Step-by-Step Guide with Customization Tips](/blog/post/how-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Docker](/blog/categories/docker)
-   [MySQL](/blog/categories/mysql)
-   [Databases](/blog/categories/databases)
-   [DevOps](/blog/categories/devops)
-   [Containerization](/blog/categories/containerization)

Introduction Docker changed the way we run and manage applications by making it easy to package, deploy, and run applications in containers. Containers let applications run in a consistent environ

[#Docker](/blog/tags/docker)[#MySQL](/blog/tags/mysql)[#Database Containerization](/blog/tags/database-containerization)+4 tags

[read more](/blog/post/how-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips)

[![Get Started with Building ReactJS and Docker: A Complete Guide](/_astro/hero.CDA9gINC_5FejQ.webp)](/blog/post/get-started-with-building-reactjs-and-docker-a-complete-guide)

## [Get Started with Building ReactJS and Docker: A Complete Guide](/blog/post/get-started-with-building-reactjs-and-docker-a-complete-guide)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [ReactJS](/blog/categories/reactjs)
-   [Docker](/blog/categories/docker)
-   [DevOps](/blog/categories/devops)
-   [Containerization](/blog/categories/containerization)
-   [Web Development](/blog/categories/web-development)

Introduction Docker is a powerful tool that allows developers to create, deploy, and run applications in a portable and scalable way. It uses containerization to encapsulate all the dependencies a

[#ReactJS](/blog/tags/reactjs)[#Docker](/blog/tags/docker)[#Dockerfile](/blog/tags/dockerfile)+5 tags

[read more](/blog/post/get-started-with-building-reactjs-and-docker-a-complete-guide)

[![How to Install and Configure Node.js on EC2 Instance Amazon Linux 2](/_astro/hero.CIYv_zEL_2aFueX.webp)](/blog/post/how-to-install-and-configure-nodejs-on-ec2-instance-amazon-linux-2)

## [How to Install and Configure Node.js on EC2 Instance Amazon Linux 2](/blog/post/how-to-install-and-configure-nodejs-on-ec2-instance-amazon-linux-2)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [EC2](/blog/categories/ec2)
-   [Node.js](/blog/categories/nodejs)
-   [Linux](/blog/categories/linux)

Introduction Node.js does not exist in the default Amazon Linux 2 repository. So, we need to add the Node.js repository to the system. In this post, we will learn how to install and configure Node

[#Node.js Installation](/blog/tags/nodejs-installation)[#Amazon Linux 2](/blog/tags/amazon-linux-2)[#AWS EC2 Setup](/blog/tags/aws-ec2-setup)+3 tags

[read more](/blog/post/how-to-install-and-configure-nodejs-on-ec2-instance-amazon-linux-2)

[![How to Install WordPress on Amazon Linux 2](/_astro/hero.CFnKBY7F_2mvbUb.webp)](/blog/post/how-to-install-wordpress-on-amazon-linux-2)

## [How to Install WordPress on Amazon Linux 2](/blog/post/how-to-install-wordpress-on-amazon-linux-2)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [EC2](/blog/categories/ec2)
-   [WordPress](/blog/categories/wordpress)
-   [LAMP Stack](/blog/categories/lamp-stack)
-   [Linux](/blog/categories/linux)

Introduction This tutorial installs WordPress on Amazon Linux 2 and configures it to run with Apache, PHP, and MariaDB. Prerequisites To follow along with this tutorial, you will need:An

[#WordPress Installation](/blog/tags/wordpress-installation)[#Amazon Linux 2](/blog/tags/amazon-linux-2)[#Apache Setup](/blog/tags/apache-setup)+5 tags

[read more](/blog/post/how-to-install-wordpress-on-amazon-linux-2)

[![How to Install PHP and MariaDB on Amazon Linux 2](/_astro/hero.BxVn8-Uf_Z1fCiGj.webp)](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2)

## [How to Install PHP and MariaDB on Amazon Linux 2](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [EC2](/blog/categories/ec2)
-   [PHP](/blog/categories/php)
-   [MariaDB](/blog/categories/mariadb)
-   [Apache](/blog/categories/apache)
-   [LAMP Stack](/blog/categories/lamp-stack)
-   [Linux](/blog/categories/linux)

Introduction In this tutorial we will set up PHP and MariaDB on Amazon Linux 2. We will get PHP working with the Apache web server, secure the MariaDB install, and then connect the two with a smal

[#PHP Installation](/blog/tags/php-installation)[#MariaDB Installation](/blog/tags/mariadb-installation)[#Amazon Linux 2](/blog/tags/amazon-linux-2)+5 tags

[read more](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2)

[![How to Install Apache Web Server on Amazon Linux 2](/_astro/hero.CFurz9Hr_Z2mT9lT.webp)](/blog/post/how-to-install-apache-web-server-on-amazon-linux-2)

## [How to Install Apache Web Server on Amazon Linux 2](/blog/post/how-to-install-apache-web-server-on-amazon-linux-2)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [EC2](/blog/categories/ec2)
-   [Apache](/blog/categories/apache)
-   [Web Server](/blog/categories/web-server)
-   [Linux](/blog/categories/linux)
-   [Firewall](/blog/categories/firewall)

Introduction In this tutorial, we will learn how to install Apache web server on Amazon Linux 2. We will also learn how to configure Apache web server to serve a simple HTML web page. Prerequi

[#Apache Installation](/blog/tags/apache-installation)[#Amazon Linux 2](/blog/tags/amazon-linux-2)[#HTTPD](/blog/tags/httpd)+4 tags

[read more](/blog/post/how-to-install-apache-web-server-on-amazon-linux-2)

6 related posts
