How to add multiple interfaces to docker container and set ip addresses manually?
I can set IP address manully by using this command:
docker run --lxc-conf="lxc.network.ipv4 = 172.17.0.12/16" -a stdin -a stdout -a stderr -i -t dockerimage /bin/bash
How to add multiple interfaces to docker container and set IP addresses manually?
2 Solutions collect form web for “How to add multiple interfaces to docker container and set ip addresses manually?”
I solved this by using these commands:
dockerContainer=$(docker run --lxc-conf="lxc.network.ipv4 = 172.17.0.21/16" -d dockerimage) sudo pipework docker0 -i eth1 $dockerContainer 172.17.0.22/24
‘docker run’ command creates eth0 and I set eth0 manually by using lxc.network.ipv4 configuration. And then I add interface eth1 by using pipework.
I’m glad you solved this, but it’s worth pointing out that this is very much against the philosophy of Docker. You should try to architect your application so that it can deal with changing IPs. Containers are supposed to be dynamic and transient. This does mean that there is a lot of on-going work in terms service-discovery and orchestration.