2、docker安装centos7镜像

摘自:https://www.cnblogs.com/adolfmc/p/12124427.html

拉取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安装

[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>

posted @ 2021-01-22 10:09  LiuYanYGZ  阅读(313)  评论(0编辑  收藏  举报