Ubuntu 1604 TLS Server 安装 Docker CE

环境: Unbuntu 16.04 TLS Server

Docker

  • Docker CE: Docker Community Edition

  • Docker EE: Docker Enterprise Edition

准备

sudo apt-get update

可能出现错误:

1
2
3
4
5
6
7
8
9
10
11
Ign:1 cdrom://Ubuntu-Server 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801) xenial InRelease
Err:2 cdrom://Ubuntu-Server 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801) xenial Release
Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs
Hit:3 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Hit:5 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:6 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease
Reading package lists... Done
E: The repository 'cdrom://Ubuntu-Server 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801) xenial Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

解决:

1
sudo vi /etc/apt/sources.list

注释掉 deb cdrom 打头的部分

deb cdrom:[Ubuntu-Server 16.04.3 LTS Xenial Xerus - Release amd64 (20170801)]/ xenial main restricted

保存后退出再次尝试 sudo apt-get update

安装

Install from a package

下载 docker-ce-18.06(获取更多版本

1
2
3
cd /usr/local/docker

wget https://download.docker.com/linux/ubuntu/dists/artful/pool/stable/amd64/docker-ce_18.06.3~ce~3-0~ubuntu_amd64.deb

安装

1
sudo dpkg -i /usr/local/docker/docker-ce_18.06.3~ce~3-0~ubuntu_amd64.deb

验证

1
docker version

其他方式

通过 rancher 提供的安装脚本在线安装

curl https://releases.rancher.com/install-docker/17.06.sh | sh

安装完成后,通过以下命令验证安装结果

sudo docker versionsudo docker info

卸载

卸载Docker CE sudo apt-get purge docker-ce

删除Docker镜像、容器、数据卷等文件 sudo rm -rf /var/lib/docker