创建新网络后:
docker network create test-net
并在主机上运行ifconfig
,列出了一个新的接口名称:
br-f2b630e4e141 Link encap:Ethernet HWaddr 02:42:48:fe:cb:86
inet addr:172.18.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
有没有办法创建此网络并指定iface名称,例如 docker1 或 test-net ?
如果是docker-compose
,我们还可以在docker-compose.yml
文件中指定iface名称吗?
答案 0 :(得分:7)
有一个--opt
选项,可以像这样使用:
docker network create --opt com.docker.network.bridge.name=br_test test-net
似乎有效:
$ ifconfig
br_test Link encap:Ethernet HWaddr 02:42:8f:3b:24:32
inet addr:172.18.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
在--opt
点docker-compose.yml
找到了https://docs.docker.com/engine/userguide/networking/#the-dockergwbridge-network
在networks:
test-net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.100.0.0/16
driver_opts:
com.docker.network.bridge.name: br_test
:
angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.6.4/$injector/modulerr?p0=sport1Feed&p1=Error…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.6.4%2Fangular.min.js%3A22%3A179)
at angular.js:38
at angular.js:4920
at q (angular.js:403)
at g (angular.js:4880)
at eb (angular.js:4802)
at c (angular.js:1914)
at Sc (angular.js:1935)
at ue (angular.js:1820)
at angular.js:33367
at HTMLDocument.b (angular.js:3431)