--net noneNow i want to try to change the subnet from the standard 172.17.0.0/16 to another ip range.
--net bridge
There are some tutorials out there which say:
but this doesa not work any more.docker run -it --net bridge --fixed-cidr "10.100.0.0/24" alpine /bin/ash unknown flag: --fixed-cidr
First you have to create new network:
Just do a verification:docker network create --driver=bridge --subnet=10.100.0.0/24 --gateway=10.100.0.1 mybrigde 6249c9a5f6c6f7e36e7e61009b9bde7ac338173d8e222e214a65b9793d36ad6c
and here we go:docker network ls NETWORK ID NAME DRIVER SCOPE a00386e6a5bc bridge bridge local 9365e4a966d0 docker_gwbridge bridge local 9d9fa338a975 host host local 6249c9a5f6c6 mybrigde bridge local 9ff819cf7ddb none null local
Removing the network bridge is easy:alpine:~# docker run -it --network mybrigde alpine /bin/ash / # ifconfig eth0 Link encap:Ethernet HWaddr 02:42:0A:64:00:02 inet addr:10.100.0.2 Bcast:0.0.0.0 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:14 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:1156 (1.1 KiB) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 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:1 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
docker network rm mybrigde
and narrowing the IP range can be done like this:
Just do a check:alpine:~# docker network create --driver=bridge --subnet=10.100.0.0/24 --ip-range=10.100.0.128/25 --gateway=10.100.0.1 mybrigde b0ba1d963a6ca3097d083d4f5fd979e0fb0f91f81f1279132ae773c06f821396
The ip address of the container is set to 10.100.0.128 as configured with --ip-range 10.100.0.128/25.alpine:~# docker run -it --network mybrigde alpine /bin/ash / # ifconfig eth0 Link encap:Ethernet HWaddr 02:42:0A:64:00:80 inet addr:10.100.0.128 Bcast:0.0.0.0 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:12 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:1016 (1016.0 B) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 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:1 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
If you are not familiar with the CIDR notation, just us this nice online tool (http://www.subnet-calculator.com/cidr.php):
No comments:
Post a Comment