1、卸载旧版本
sudo apt-get remove docker docker-ce docker-engine docker.io
2、首次安装,安装镜像仓库
2.1 更新apt软件包索引
sudo apt-get update
2.2 添加docker官方GPG秘钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
2.3 配置仓库
vi /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
3、安装docker-ce
3.1 更新版本
sudo apt-get update
3.2 安装
3.2.1 安装最新版本
sudo apt-get install docker-ce
3.2.2 安装指定版本
sudo apt-get install docker-ce=<VERSION>
》安装 17.03.2~ce-0~ubuntu-xenial 版本
sudo apt-get install docker-ce=17.03.2~ce-0~ubuntu-xenial
可能出现的错误
此问题源于libltdl7版本过低,ubuntu16.04默认无更高版本。
下载:
wget http://launchpadlibrarian.net/236916213/libltdl7_2.4.6-0.1_amd64.deb
安装:
sudo dpkg -i libltdl7_2.4.6-0.1_amd64.deb
再次安装 =》 跳转3.1
4、测试安装
sudo docker run hello-world
就此安装成功!!!