1、更新系统软件
$ sudo apt-get update
2、安装依赖包
$ sudo apt-get install
$ sudo apt-get install apt-transport-https
$ sudo apt-get install ca-certificates
$ sudo apt-get install curl
$ sudo apt-get install software-properties-common
3、添加官方密钥
执行该命令时,如遇到长时间没有响应说明网络连接不到docker网站,需要使用代-理进行。(建议更换源)
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
显示OK,表示添加成功.
4、添加仓库
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
5、再次更新软件
我们需要再次把软件更新到最新,否则下一步有可能会报错,(ubuntu源自行更换为国内源,推荐阿里源)
$ sudo apt-get update
6、安装docker
默认就会安装最新版
$ sudo apt-get install docker-ce
7、查看docker版本
$ docker -v
显示“Docker version xx.xx.x-ce, build afdb6d4”字样,表示安装成功。