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?

  • Docker - Local Development on container
  • Connecting to a mysql running on a Docker container ubuntu 16.04
  • docker - how can we export/import (or save/load) only the new changes?
  • SSL handshake failure with node.js https
  • (spotify:1): Gtk-WARNING **: cannot open display: unix
  • Obtaining a docker image's parent images
  • Docker + Jenkins + AWS
  • Error travis on phpunit when I add docker login
  • Cannot connect to MySQL docker instance via DataGrip application
  • How to get a docker image to run an executable
  • MySQL stops randomically with Magento 2
  • Hit a service running on localhost from inside a docker image
  • 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.