1. 下載docker rpm
https://docs.docker.com/engine/installation/#supported-platforms
2. 安裝
[root@centos]# yum localinstall docker-ce-17.06.0.ce-1.el7.centos.x86_64.rpm
3. 使用國內(nèi)加速器
[root@centos]# vi /etc/docker/daemon.json
內(nèi)容如下(注意json格式)
{
"registry-mirrors": ["https://tu9b5nt0.mirror.aliyuncs.com"]
}
[root@centos]# sudo systemctl daemon-reload
4. 啟動并加載在開機啟動
[root@centos]# systemctl enable docker
[root@centos]# systemctl start docker
5. 測試
[root@centos]# docker run hello-world
6. 卸載
- 列出你安裝過的包
[root@centos]# yum list installed | grep docker
- 刪除安裝包
[root@centos]# yum -y remove docker-engine.x86_64
- 刪除鏡像/容器等
[root@centos]# rm -rf /var/lib/docker
7. 常見問題
centos7 Docker啟動容器但是啟動時報
==WARNING: IPv4 forwarding is disabled. Networking will not work==
處理:
[root@centos]# vi /etc/sysctl.conf
# 或者
[root@centos]# vi /usr/lib/sysctl.d/00-system.conf
# 添加如下代碼:
net.ipv4.ip_forward=1
# 重啟network服務
[root@centos]# systemctl restart network
# 查看是否修改成功
[root@centos]# sysctl net.ipv4.ip_forward
# 如果返回為“net.ipv4.ip_forward = 1”則表示成功了