1.更换镜像
(1)备份原来的源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bakcup
(2)编辑sources.lists
sudo vim /etc/apt.sources.list
添加如下内容:
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
2.安装步骤
(1)卸载本地之前旧版的docker可使用如下命令:
sudo apt-get remove docker docker-engine docker-ce docker.io
(2)更新apt索引
sudo apt-get update
(3)安装以下包以使apt可以通过HTTPS使用存储库(repository)
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
(4)添加Docker官方的GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
(5)使用下面的命令来设置stable存储库
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
(6)再次更新apt索引
sudo apt-get update
(7)列出可用版本
apt-cache madison docker-ce
(8)安装指定版本
sudo apt-get install docker-ce=18.03.0~ce-0~ubuntu
我在这里安装的版本是18.03.0版本
sudo apt-get install docker -ce 如果使用该命令的话,默认安装最新版本,当然在自定义测试或者学习可以使用该命令,但是在公司生产环境下最好指定版本进行安装。
(9)查看docker服务状态(是否启动)
systemctl status docker
如果没有启动可使用sudo systemctl start docker或者sudo service docker start命令进行启动
(10)查看详细docker版本信息
docker version