Docker Containers with different Network Interface

Problem:
I want to have multiple VPN Servers running in Docker containers each with there own public IP.

With the -p parameter I am able to connect to each one separately but the Public ip that I see is the eth0 interface not the one that I want it to be (eth0:1) so how can I create a new docker0 interface that uses eth0:1 as interface for the traffic?

  • Best way to run two docker compose apps behind nginx on one host machine?
  • Enable logging in docker mysql container
  • Why the virtual size still the same after delete a file from container with rm?
  • Why is my official Ghost.org Docker container serving old content after I refresh my browser even though Ghost / Node are in development mode?
  • Failed to find a usable hardware address from the network interfaces
  • Docker-compose using host environment variable
  • Best regards and thanks.

  • Schedule a container with docker swarm using gpu memory as a constraint
  • Docker: Nginx + PHP-FPM and multiple sites
  • error during connect: … http: server gave HTTP response to HTTPS client on any docker command with remote host
  • docker + apt-add-repository: 'ascii' codec can't decode byte
  • Why is PyCharm killing my subprocess.Popen?
  • Docker and file upload server
  • One Solution collect form web for “Docker Containers with different Network Interface”

    Docker doesn’t uses network outside of it .
    For the connection between the host to container from outside the world use port bindings.
    Expose the port in Dockerfile when creating docker image
    Expose Docker Container to Host :
    Exposing container is very important for the host to identify in which port container runs.
    -p in docker run command used to expose the ports.
    Syntax : docker run -p host_ip:host_port:container_port image_name
    e.g., docker run -itd -p 192.168.134.122:1234:1500 image_name
    This binds port 1500 of the container to port 1234 on 192.168.134.122 of the host machine.
    Use Iptables to view the network process – iptables -L -n -t nat

      Now the request send to host_ip (192.168.134.122) and port (1243) is redirect to container with ip (172.17.0.2) and port (1500).
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.