Docker安装(Ubuntu、CentOS)

1、Ubuntu

https://docs.docker.com/engine/install/ubuntu/ 官网教程

 1 #1 卸载原来的docker
 2 sudo apt-get remove docker docker-engine docker.io containerd runc
 3 [如果卸载不够干净可以参考](https://www.cnblogs.com/shmily3929/p/12085163.html)
 4 
 5 #2 更新源
 6 sudo apt-get update
 7 
 8 #3 安装网络https访问
 9 sudo apt-get install 10     apt-transport-https 11     ca-certificates 12     curl 13     gnupg 14     lsb-release
15 
16 #4 安装秘钥
17 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
18 
19 #5
20 
21 >>>x86_64/amd64<<<
22  echo 23   "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu 24   $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
25   
26 >>>armhf<<<
27  echo 28   "deb [arch=armhf signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu 29   $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
30   
31 >>>arm64<<<
32  echo 33   "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu 34   $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
35   
36 #6 查看需要安装docker的列表
37 apt-cache madison docker-ce
38 
39 #7 选择好版本执行安装(不选择默认安装最新)
40 sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
41 本文采用:18.09.0版本
42 sudo apt-get install docker-ce=5:18.09.0~3-0~ubuntu-bionic docker-ce-cli=5:18.09.0~3-0~ubuntu-bionic containerd.io
43 
44 #8 查看是否安装成功
45 docker --version
46 Docker version 18.09.0, build 4d60db4 显示成功

2、CentOS

https://docs.docker.com/engine/install/centos/ 官网教程

 1 #1 卸载原来的docker
 2 sudo yum remove docker  3                   docker-client  4                   docker-client-latest  5                   docker-common  6                   docker-latest  7                   docker-latest-logrotate  8                   docker-logrotate  9                   docker-engine
10                   
11 #2 安装yum工具
12 sudo yum install -y yum-utils
13 
14 #3 设置仓库
15 sudo yum-config-manager 16     --add-repo 17     https://download.docker.com/linux/centos/docker-ce.repo
18     
19 #4 查看可安装的版本
20 yum list docker-ce --showduplicates | sort -r
21 
22 #5 选择好版本执行安装(不选择默认安装最新)
23 sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
24 通过其完全合格的软件包名称安装特定版本,该软件包名称是软件包名称(docker-ce)加上版本字符串(第二列),从第一个冒号(:)到第一个连字符,以连字符(-)分隔。例如,docker-ce-18.09.025 sudo yum install docker-ce-18.09.0 docker-ce-cli-18.09.0 containerd.io
26 
27 #6 启动docker
28 sudo systemctl start docker
29 
30 #7 查看是否安装成功
31 docker --version
32 Docker version 18.09.0, build 4d60db4 显示成功

 

Docker安装(Ubuntu、CentOS)

上一篇:powershell无法下载NuGet


下一篇:Mac终端ssh连接VMware 虚拟机