其他分享
首页 > 其他分享> > docker自定义bridge网络

docker自定义bridge网络

作者:互联网

>>> docker network create -d bridge bridge-net  # 创建一个名为bridge-net的网络

# 测试,启动两个容器,并且接入到bridge-net网络中
>>> docker run -it --name alpine1 --network bridge-net --rm alpine:latest sh
>>> docker run -it --name alpine2 --network bridge-net --rm alpine:latest sh

# 查看bridge-net网络信息
1. $ docker network inspect bridge-net
2. [
3. {
4. "Name": "bridge-net",
5. "Id":
"6d5dba74ed5373e31d7104be296de4dd380d4748440e2cfb944effa1
7b5314c6",
6. "Created": "2019-08-04T15:02:01.5623202Z",
7. "Scope": "local",
8. "Driver": "bridge",
9. "EnableIPv6": false,
10. "IPAM": {
11. "Driver": "default",
12. "Options": {},
13. "Config": [
14. {
15. "Subnet": "172.18.0.0/16",
16. "Gateway": "172.18.0.1"
17. }
18. ]
19. },
20. "Internal": false,
21. "Attachable": false,
22. "Ingress": false,
23. "ConfigFrom": {
24. "Network": ""
25. },
26. "ConfigOnly": false,
27. "Containers": {
28.
"3716dd6f65a4be2926a16cdb9eefe9635abbe3006823d03792a745f4
2cf1c867": {
29. "Name": "alpine2",
30. "EndpointID":
"ad796df211292fa1548a9d02ff340137908f636e36
257e2c1303ec9d0279018d",
31. "MacAddress": "02:42:ac:12:00:03",
32. "IPv4Address": "172.18.0.3/16",
33. "IPv6Address": ""
34. },
35.
"d4911957574768639358cfe4c372c4f7eda0efb50652cfe4bf549b37
37e6cee2": {
36. "Name": "alpine1",
37. "EndpointID":
"55f087cf94709f1c7dae203fdfcf2e99412344a4f0
21804ed9bef46f1fecf96f",
38. "MacAddress": "02:42:ac:12:00:02",
39. "IPv4Address": "172.18.0.2/16",
40. "IPv6Address": ""
41. }
42. },
43. "Options": {},
44. "Labels": {}
45. }
46. ]
可以看到都是在同一网段172.18.0.x中,彼此之间是可以互相通信的
>>> ping alpine2

标签:bridge,false,自定义,--,172.18,docker,net
来源: https://www.cnblogs.com/weiweivip666/p/16284218.html