1. 先更新Ubuntu系统apt-get的镜像源,可以提升更新安装速度
-
原文件备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
-
编辑源列表文件
sudo gedit /etc/apt/sources.list
-
将原来的列表删除,添加如下内容(阿里镜像源)
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multivers
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse -
运行 sudo apt-get update
如果出错:
E: 无法获得锁 /var/lib/apt/lists/lock - open (11: 资源暂时不可用)
E: 无法对目录 /var/lib/apt/lists/ 加锁解决方案:
sudo rm /var/lib/apt/lists/lock
2. 安装Docker
-
更新系统软件:sudo apt-get update
-
安装依赖包
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
-
添加 Docker 的官方 GPG 密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
-
验证您现在是否拥有带有指纹的密钥
sudo apt-key fingerprint 0EBFCD88
-
设置稳定版仓库
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
-
更新
$ sudo apt-get update
-
安装最新的Docker-ce
sudo apt-get install docker-ce
-
启动
sudo systemctl enable docker
sudo systemctl start docker -
重启 docker 服务
$ sudo service docker restart
-
查看Docker版本
sudo docker version or sudo docker -v
3. 配置Docker镜像加速器
-
修改配置文件:/etc/docker/daemon.json,写入你的阿里云或者其他云的加速器即可
sudo docker gedit /etc/docker/daemon.json
-
重启Docker生效
sudo systemctl daemon-reload sudo systemctl restart docker