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?

  • Missing tag after docker stack deploy
  • How to prevent escaping of an ENV variable passed into ruby application in docker container
  • Docker jetty container JVM memory allocation
  • How to push a docker image to a private repository
  • Flask web app, Node.js (queue) worker. Can't make docker work
  • Python exceptions in Docker logs marked as stream: stdout
  • Docker Volumes mounting issue
  • Run DDL-script generated by Entity Framework does not create tables in Docker container
  • Docker registry:2 won't start
  • Docker Reverse Proxy To Subdomains
  • docker double service names
  • Dockernized Nginx + (Rails+Unicorn)+Redis+PostgreSQL:connect() failed (111: Connection refused)
  • 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.