Answer the question
In order to leave comments, you need to log in
How to automatically execute script on host after docker container is started?
Initially there is: a host running docker daemon. Disabled iptables and ip-masq in startup options. The host has an external network interface (eth0) connected to the bridge (br0), the bridge has a static address configured (192.168.0.10/24).
You need to run several containers and assign a fixed address to each:
# docker run -d --name app1 local/app1
# ip link add app1-int type veth peer name app1-ext
# brctl addif br0 app1-ext
# ip link set netns $(docker-pid app1) dev app1-int
# nsenter -t $(docker-pid app1) -n ip link set app1-int up
# nsenter -t $(docker-pid app1) -n ip addr add 192.168.0.21/24 dev app1-int
# nsenter -t $(docker-pid app1) -n ip route del default
# nsenter -t $(docker-pid app1) -n ip route add default via 192.168.0.1 dev app1-int
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question