docker安装centos7镜像

  1. 拉取centos7镜像
[root@localhost ~]# docker pull centos:7
  1. 启动镜像centos7,如果不指定 /bin/bash,容器运行后会自动停止
[root@localhost ~]# docker run -d -i -t <IMAGE ID> /bin/bash
  1. 进入容器
[root@localhost ~]# docker exec -it <CONTAINER ID> bash
  1. 进入后发现没有ifconfig,直接yum安装
    ifconfig报错
[root@8f10fbd6bd5a /]# yum install -y net-tools
  1. 无法ping外网,查找资料重建docker0网络解决,资料地址
[root@localhost ~]# pkill docker
[root@localhost ~]# iptables -t nat -F
[root@localhost ~]# ifconfig docker0 down
[root@localhost ~]# brctl delbr docker0
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker start <CONTAINER ID>

猜你喜欢

转载自blog.csdn.net/marke_huang/article/details/82996909