docs/guides/install-docker.md

99 lines
3.9 KiB
Markdown
Raw Normal View History

2023-06-26 11:17:19 +00:00
---
title: How to install Docker
description: How to install Docker on Ubuntu 22.04
published: true
date: 2023-06-26T10:57:30.081Z
2023-06-26 12:12:35 +00:00
tags: docker, ubuntu, installation, containerization, container, linux, server, ubuntu
2023-06-26 11:17:19 +00:00
editor: markdown
dateCreated: 2023-06-26T10:43:59.640Z
---
2023-06-26 12:18:58 +00:00
# How to install Docker on Ubuntu 22.04
2023-06-26 11:17:19 +00:00
This guide provides step-by-step instructions for installing Docker Community Edition (CE) on Ubuntu, specifically tested on version 22.04. Docker is a powerful tool for containerization, allowing you to separate different services into individual containers and offering better resource efficiency compared to virtual machines.
2023-06-26 11:47:49 +00:00
## Prerequisites
- A system running Ubuntu 22.04
- A user account with sudo privileges
- An internet connection
## Get Started
2023-06-26 11:29:17 +00:00
- Begin by updating your apt repository to ensure you have the latest package information and dependencies. Open a terminal and run the following command:
```bash
sudo apt update
2023-06-26 11:29:17 +00:00
```
2023-06-26 11:17:19 +00:00
This command will refresh the package lists and update any outdated packages on your system.
- Next, you need to ensure that the curl utility is installed. If you already have curl installed, you can skip this step. Otherwise, execute the following command in the terminal to install it:
2023-06-26 11:29:17 +00:00
```bash
sudo apt install curl
2023-06-26 11:17:19 +00:00
```
2023-06-26 11:29:17 +00:00
2023-06-26 11:17:19 +00:00
This command will download and install curl from the Ubuntu repositories.
2023-06-26 11:29:17 +00:00
- Now, you can proceed with the installation of Docker. Docker provides a convenient installation script that you can run to automatically set up the necessary components. Execute the following command in the terminal:
```bash
2023-06-26 11:17:19 +00:00
curl -sSL https://get.docker.com/ | CHANNEL=stable bash
```
2023-06-26 11:29:17 +00:00
2023-06-26 11:17:19 +00:00
This command downloads the Docker installation script and pipes it to the bash shell, which executes the script. The CHANNEL=stable option ensures that the stable version of Docker is installed.
2023-06-26 11:29:17 +00:00
- Once the installation process is complete, you can verify that Docker is working correctly. Run the following command in the terminal:
```bash
sudo docker --version
2023-06-26 11:17:19 +00:00
```
This command displays the version of Docker installed on your system. You should see an output similar to the following:
2023-06-26 11:29:17 +00:00
```bash
➜ ~ sudo docker --version
2023-06-26 11:17:19 +00:00
Docker version 23.0.6, build ef23cbc
```
2023-06-26 12:04:48 +00:00
## Finished
2023-06-26 11:29:17 +00:00
Congratulations! You have now installed Docker Community Edition on your Ubuntu machine. Docker is ready to be used, allowing you to leverage the power of containerization for your projects and applications.
2023-06-26 14:42:46 +00:00
Certainly! Here's the raw Markdown syntax for the rootless part, enclosed in a code block:
# Optional: Running Docker in Rootless Mode
By default, Docker requires root privileges to run. However, Docker also supports running in rootless mode, which allows non-root users to use Docker without needing to escalate their privileges. Keep in mind that rootless mode has some limitations and may not be suitable for all use cases.
Warning: Rootless Mode Implications
Running Docker in rootless mode has the following implications:
Some advanced features, such as accessing privileged resources or running privileged containers, may be restricted.
Network functionality may be limited, and you may encounter issues when trying to bind to privileged ports.
Docker volumes may have reduced functionality or performance.
If you understand these implications and still wish to run Docker in rootless mode, you can follow the steps below:
Install the necessary dependencies for rootless mode by running the following command in the terminal:
```bash
curl -fsSL https://get.docker.com/rootless | sh
```
This command downloads a script specifically for rootless mode and executes it.
After the installation completes, you can initialize your Docker environment by running the following command which starts the rootless Docker service.:
```bash
sudo systemctl --user start docker
```
To verify that Docker is running in rootless mode, use the following command:
```bash
docker version
```
You should be able to run docker commands without the need of sudo privileges!