centos7 安装docker

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. 使用国内加速器

[root@centos]# vi /etc/docker/daemon.json

内容如下(注意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”则表示成功了
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容