Docker 容器间网络通讯

Docker About 870 words

创建网络

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
Views: 1,794 · Posted: 2022-01-25

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

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

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


Today On History
Browsing Refresh