在2017年的3月1號之後,Docker的版本命名分爲CE(Community Edition,社區版)版本和EE(Enterprise Edition,企業版)版本。我們使用CE版本就夠了。
基本主流的操作系統都可以安裝。
我非常建議大家在Linux下安裝,而不是在Windows下,因爲Linux版Docker是企業生產用的。
1.CentOS
官方安裝文檔:https://docs.docker.com/install/linux/docker-ce/centos/
服務器的系統是CentOS7.4的
[root@VM_82_178_centos ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
#安裝依賴包
yum install -y yum-utils device-mapper-persistent-data lvm2
#添加Docker軟件包源
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
#安裝Docker CE
yum install docker-ce -y
#啓動
systemctl start docker
#開機啓動
systemctl enable docker
#查看Docker信息
docker info
2.Ubuntu 上安裝
apt-get update
安裝證書:
apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
添加docker源的key:
sudo apt-key fingerprint 0EBFCD88
pub 4096R/0EBFCD88 2017-02-22
Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid Docker Release (CE deb) <[email protected]>
sub 4096R/F273FCD8 2017-02-22
添加docker軟件包源:
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
跟新apt包索引:
sudo apt-get update
安裝docker ce
apt-get install docker-ce
3.配置Docker加速器
Docker Hub 提供衆多鏡像,你可以從中自由下載數十萬計的免費應用鏡像, 這些鏡像作爲 docker 生態圈的基石,是我們使用和學習 docker 不可或缺的資源。爲了解決國內用戶使用 Docker Hub 時遇到的穩定性及速度問題 DaoCloud 推出永久免費的新一代加速器服務。
Linux:
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://bc437cce.m.daocloud.io
[root@localhost ~]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://bc437cce.m.daocloud.io
docker version >= 1.12
{"registry-mirrors": ["http://bc437cce.m.daocloud.io"]}
Success.
You need to restart docker to take effect: sudo systemctl restart docker
[root@localhost ~]#
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# systemctl stop docker
[root@localhost ~]# ps -ef|grep docker
root 15185 3300 0 01:39 pts/1 00:00:00 grep --color=auto docker
[root@localhost ~]# systemctl start docker
[root@localhost ~]# ps -ef|grep docker
root 15191 1 2 01:39 ? 00:00:00 /usr/bin/dockerd
root 15198 15191 0 01:39 ? 00:00:00 docker-containerd --config /var/run/docker/containerd/containerd.toml
root 15325 3300 0 01:39 pts/1 00:00:00 grep --color=auto docker
[root@localhost ~]#