Ubuntu 20.0.4 安装 Docker
作者:互联网
Ubuntu 20.0.4 安装 Docker
卸载旧版本 Docker
sudo apt-get remove docker docker-engine docker.io containerd runc
配置软件源
更新软件源并安装依赖包
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
添加 Docker 官方软件包密钥
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
验证密钥是否安装成功
toor@toor:~/Desktop$ sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker@docker.com>
sub rsa4096 2017-02-22 [S]
添加软件源
查询当前系统所基于的 Debian 版本,得到以下回显
toor@toor:~/Desktop$ cat /proc/version
Linux version 5.8.0-63-generic (buildd@lgw01-amd64-035) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #71~20.04.1-Ubuntu SMP Thu Jul 15 17:46:08 UTC 2021
通过查询得知 Debian 9 对应的代号为 stretch ,之后执行以下命令写入 docker 软件源
echo 'deb https://download.docker.com/linux/debian stretch stable' | sudo tee -a /etc/apt/sources.list.d/docker.list
正常写入回显
toor@toor:~/Desktop$ echo 'deb https://download.docker.com/linux/debian stretch stable' | sudo tee -a /etc/apt/sources.list.d/docker.list
[sudo] password for toor:
deb https://download.docker.com/linux/debian stretch stable
安装 Docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
安装之后可以配置一下 Docker 镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
配置好后执行以下命令进行测试
sudo docker run hello-world
得到以下回显显示为正常
卸载 Docker
卸载软件
sudo apt-get purge docker-ce docker-ce-cli containerd.io
删除镜像、容器、自定义配置等文件
sudo rm -rf /var/lib/docker
安装 Docker-Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose -v
回显版本号则安装成功
卸载 Docker-Compose
sudo rm /usr/local/bin/docker-compose
标签:20.0,sudo,apt,卸载,toor,Ubuntu,Docker,docker 来源: https://blog.csdn.net/LYJ20010728/article/details/119023051