开发环境为Ubuntu 16.04 LTS 64位系统
通过apt的docker官方源安装最新的Docker CE(Community Edition),即Docker社区版
1.更新apt
sudo apt-get update
2.使用下列指令通过HTTPS使用存储库(repository)
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
3. 安装curl,类似于下载
sudo apt-get -y install curl
4. 添加Docker官方GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
可能报错:
curl: (28) Operation timed out after 300415 milliseconds with 0 out of 0 bytes received
gpg: no valid OpenPGP data found.
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to download.docker.com:443
解决:
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D8576A8BA88D21E9
重新输入:curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
显示 OK 成功
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. 安装docker-ce
sudo apt-get install -y docker-ce
可能报错:E: There were unauthenticated packages and -y was used without --allow-unauthenticated
解决:sudo apt-get install docker-ce
8. 列出可用版本:
apt-cache madison docker-ce
9. 选择安装
sudo apt-get install docker-ce=17.12.1~ce-0~ubuntu
10.启动docker
sudo systemctl start docker
11. hello world 开启奇妙之旅
sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
安装成功!