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?

  • Error: BiocInstaller:::BIOC_VERSION == “3.1” is not TRUE
  • Rails can't find a temporary directory when run inside Docker container
  • Import Error: paho.mqtt.client not found
  • Run jhipster-registry in production
  • How to access lower layer files in docker?
  • set max time a docker container can be open
  • Log management of various docker containers
  • Dynamically pick the user GUI and UID who's running Docker at the host from entrypoint
  • 2 processes on same port?
  • Can't start docker-compose with systemd: “aufs au_opts_verify: dirperm1 breaks the protection by the permission bits on the lower branch” error
  • Access running docker container filesystem
  • Error while publising to docker on Azure from Visual Studio 2015
  • 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.