How to install Docker (linux version)
Before installing, please check Docker’s official documentation!
Docker official website help documentation
According to the official documentation of Docker, select the system you install. There are corresponding detailed installation steps. Here is the Ubuntu system as an example:
1 Preliminary uninstallation of the old Docker
If you have old Docker installed on your system, please uninstall them first
sudo apt-get remove docker docker-engine docker.io containerd runc
For example, the old version of Docker is not installed on our computer, so it can be installed directly!
However, this uninstallation cannot completely delete all Docker in the old folder. Therefore, to completely delete it, use the following command:
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
2 Update and install basic dependency packages
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo apt install apt-transport-https software-properties-common
3 Add Docker’s official GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4 Add the Docker repository to the APT source
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
5 Initial settings
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
6 Install Docker
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce #从Docker版本库中安装
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin #官方文档中给出的从Ubuntu库中安装
sudo apt-get install docker-compose #安装docker命令工具包
7 Complete the installation and test the running status
sudo systemctl status docker
The following content appears, indicating that it is running and in good condition:
At this point we have completed the installation of the Docker environment!