Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


Docker 容器间网络通讯

Docker 大约 870 字

创建网络

docker network create test-network

查看网络

docker network ls

输出

# docker network ls
NETWORK ID          NAME                     DRIVER              SCOPE
109ab6e25406        bridge                   bridge              local
cc119d540517        host                     host                local
e5e7041ce376        none                     null                local
714f23588ce6        test-network             bridge              local

创建容器指定网络

docker run -id --name=c_centos1 --network=test-network --network-alias=centos1 centos:8
docker run -id --name=c_centos2 --network=test-network --network-alias=centos2 centos:8
docker run -id --name=c_centos3 --network=test-network --network-alias=centos3 centos:8

进入容器 ping 网络

docker exec -it c_centos1 bash
docker exec -it c_centos2 bash
docker exec -it c_centos3 bash

ping

ping c_centos1
ping c_centos2
ping c_centos3
阅读 913 · 发布于 2022-01-25

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批