Install docker in ubuntu environment

Install docker in ubuntu environment

There are many tutorials on how to install docker online, but they are old. Now we provide the best and simplest official docker installation tutorial.

System Requirements

The following system environments have been tested

  • Ubuntu Lunar 23.04
  • Ubuntu Kinetic 22.10
  • Ubuntu Jammy 22.04 (LTS)
  • Ubuntu Focal 20.04 (LTS)

Uninstall the old version of docker

Some distributions of Linux systems may have unofficial docker-related components. Uninstall them here,
otherwise version conflicts will be very troublesome.

for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done

Install docker from command line

1. Set up docker software source

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

2. Install the latest version

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

3. Verification

sudo docker run hello-world

The above command downloads the test image and generates the container. When the container runs, it prints a successful message and exits, indicating that the installation is OK.

reference

[0] https://docs.docker.com/engine/install/ubuntu/

Guess you like

Origin blog.csdn.net/m0_72734364/article/details/133267088