> For the complete documentation index, see [llms.txt](https://42-guide.gitbook.io/42-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://42-guide.gitbook.io/42-guide/docker/installation.md).

# Installation

## Linux

## How to Install Docker on Linux (Step by Step)

Here’s a simple guide to install Docker on your Linux system from scratch.

***

#### **Step 1: Update Your System**

Always start by updating your package list to ensure you have the latest software versions.

Open a terminal and run:

```bash
sudo apt update && sudo apt upgrade -y
```

#### **Step 2: Install Required Packages**

Install a few prerequisites needed for Docker installation.

```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
```

***

#### **Step 3: Add Docker’s Official GPG Key**

Download and add Docker’s GPG key to verify the software package.

```bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```

***

#### **Step 4: Add Docker’s Repository**

Add Docker’s repository to your system so you can install the latest version.

```bash
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
```

***

#### **Step 5: Install Docker**

1. Update your package list again to include Docker’s repository.

   ```bash
   sudo apt update
   ```
2. Install Docker.

   ```bash
   sudo apt install docker-ce docker-ce-cli containerd.io -y
   ```

***

#### **Step 6: Verify Installation**

To check if Docker is installed correctly, run:

```bash
docker --version
```

It should display the installed version of Docker.

***

#### **Step 7: (Optional) Run Docker Without `sudo`**

By default, Docker needs `sudo` to run. If you want to use Docker without `sudo`:

1. Add your user to the `docker` group:

   ```bash
   sudo usermod -aG docker $USER
   ```
2. Log out and log back in to apply the changes.

***

#### **Step 8: Test Docker**

Run a test container to confirm everything works:

```bash
sudo docker run hello-world
```

You should see a message saying Docker is installed and working!

***

#### **Notes:**

* These steps are for Ubuntu-based Linux distributions. For other distributions (e.g., CentOS, Fedora), steps may vary slightly.
* Always refer to the official Docker documentation for the latest instructions.

source -> i found nice video for Learning Docker ->&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://42-guide.gitbook.io/42-guide/docker/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
