问题引入
1、首先,我暴露了端口 8080 ,创建了映射也是 -p 8080:8080
2、容器内部执行 curl 127.0.0.1:8080/hello 是可以正常访问的
docker network create –driver bridge –subnet 172.03^C.1/16 –gateway 172.03.0.0 my_net
1 | [root@localhost ~]# docker images |
原因分析
以下都是我的猜测而已。
1 | 可能是因为的克隆虚拟机导致的。 |
解决方案
启动容器时,使用 –net host 来指定,使用 host 方式启动容器。
默认是 bridge,host 可以避免 ip 重复问题。
1 | [root@localhost ~]# docker rm -f a1 #===> 删除原有容器 |