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?

  • How to debug why I got 301 HTTP code instead of 200 when using docker nginx-proxy image
  • Dockerfile: Setup SSH key for Bitbucket
  • Docker: Mount directory from one container to another
  • How to run docker image as singleton
  • Jenkins - Docker integration
  • How to access environment variables in grunt application *after* it has been built
  • tinyproxy not tracing xmlhttprequest
  • Using shared runners to access the gitlab registry
  • Using golang connect to docker container with functional tty
  • Run LiveServerTestCase from Docker Selenium with Django 1.11
  • docker how to set containers to only use ips within a sepcified range
  • docker-compose caches run results
  • 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.