Docker Containers with different Network Interface
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 regards and thanks.
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).