Docker Community Forums

Share and learn in the Docker community.

Multiple Public IPs for container

Expected behavior

I have a Ubuntu VM on Azure with 2 NICs and public IPs + NSG with the correct Port and docker-compose config. I assigned the Port config so for example my management containers are available on one IP (the backend) and the other container on the other IP (Frontend).

For example the wordpress container should be publicly available and has the config:

ports:

  • “10.1.0.4:80:80”

and my backend service have:

ports:

  • “10.1.0.5:80:8080”

These private 10.1.x IPs are pointing to the correct public IPs set up and the Ports are allowed in the NSG.

Actual behavior

The backend containers are available as expected, but I cannot reach the Frontend containers. I think the problem is that it ignores the IP assignment in the ports section of my compose file.

Additional Information

Steps to reproduce the behavior

  1. Create Ubuntu VM
  2. Add 2 NICs with public ip
  3. create 2 services with docker-compose
  4. set up the port config for the service to one public ip and the second container to the other public ip
  5. only one (probably the main IP) is availbale from outside

I tried to run a container from the following post:

Advanced Docker networking // Custom outgoing IP | by Joachim Havloujian | Medium

And it states that it used the backend IP address, the question for me is now how can I assign the container to a specific host interface ? My first Idea was to create 2 new docker networks, but I cant find the point how I can assign a new network to a host interface with the bridge driver.