🐳

How to install Docker to Ubuntu 22.04

2024/07/04に公開

Here is a procedure to install docker to ubuntu 22.04.

1. Update System

sudo apt update

2. Install Prerequisites

Install the necessary prerequisites for Docker.

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

3. Add Docker’s Official GPG Key

Add Docker's official GPG key.

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

4. Add Docker Repository

Add the Docker repository to APT sources.

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

5. Update Package Database

Update package database again to include Docker's packages.

sudo apt update

6. Install Docker

Finally, install Docker.

sudo apt install docker-ce

7 Check Docker

docker --version

8. Run Docker daemon

Run the Docker daemon.

sudo systemctl start docker
# or
sudo dockerd &

When you want to stop:

sudo systemctl stop docker
# or
dockerd &

9. In the end

It's over, enjoy the docker life.

All commands
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
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
sudo apt update
sudo apt install docker-ce
docker --version

All commands no sudo(option. operation is not guaranteed)
apt update
apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
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" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install docker-ce
docker --version

Discussion