docker 第10.2章 Docker网络-网络模式 docker 第10.2章 Docker网络-网络模式

2023-06-08

一、总体介绍

01.jpg

  • bridge 模式:使用--network  bridge 指定,默认使用docker0

  • host 模式:使用--network host 指定

  • none 模式:使用--network none 指定

  • container 模式:使用--network container:NAME 或者容器 ID 指定

二、容器实例内默认网络 IP 生产规则

下载 ubuntu 镜像

docker pull ubuntu

01.jpg

启动两个 ubuntu 容器实例

docker run -it --name u1 ubuntu bash

01.jpg

docker run -it --name u2 ubuntu bash

01.jpg

docker inspect 容器 ID or 容器名字

docker inspect u1 | tail -n 20

01.jpg

docker inspect u2 | tail -n 20

https://file.lulublog.cn/images/3/2023/06/ZHGVV6x8YT2RXGWfa0FdfVEdgfxAHR.jpg

关闭 u2 实例,新建 u3,查看 ip 变化

exit
docker run -it --name u3 ubuntu bash

https://file.lulublog.cn/images/3/2023/06/jlaQI8DziRQSIVwVw8lu9AUoqDwdAp.jpg

docker inspect u3 | tail -n 20

https://file.lulublog.cn/images/3/2023/06/T36zdY6663XbM64FbBxkfx6ucnm2Bx.jpg

结论:docker 容器内部的 ip 是有可能会发生改变的

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开微信扫一扫,即可进行扫码打赏哦

阅读 188

docker文章

带到手机上看