0

On my Droplet, let's say

  • i have IP ADDRESS: X.X.X.99
  • I assign a new floating IP address like: X.X.X.100

I would like to run two docker container like that

  • docker run --name mynginx1 -p X.X.X.99:80:80 nginx
  • docker run --name mynginx2 -p X.X.X.100:80:80 nginx

The second command is not working so far.

What should i do to make it work?

Thank you!

Antoine

  • Can't you use the `--link` option? – Grimmy Jul 20 '17 at 09:51
  • The second command should not be working because port 80 on your machine is already mapped to your x.x.x.99 container. What is the goal of your setup? As Grimmy suggested you may use the link option. What about docker-compose ? – getjackx Jul 20 '17 at 09:53
  • docker compose will not change anything. we can map a container to a specific Ip address and port (https://stackoverflow.com/questions/25036895/how-to-expose-docker-containers-ip-and-port-to-outside-docker-host-without-port) my question is: how to configure floating ip address from digital ocean so this setup can work. – user3413813 Jul 20 '17 at 09:55

1 Answers1

0

As DigitalOcean says : "Network traffic between a Floating IP and a Droplet flows through an anchor IP, which is an IP address that is aliased to a Droplet's public network interface (eth0)."

This means you must use the anchor Ip associated to X.X.X.100 in your second command, not X.X.X.100 directly.

Use "ip addr show eth0" to find the anchor Ip.

Alexandre Fenyo
  • 4,526
  • 1
  • 17
  • 24
  • but it does't work with you have 10 floating ip adress and I want to attribute each floating Ip adress to a specific docker container, right? – user3413813 Jul 24 '17 at 09:08
  • You can use 10 ports (80 to 89 for instance) to let your droplet dispatch requests to the container of your choice. For instance, use http://FloatingIP1/ to access first container, http://FloatingIP2:81/ to access second container, http://FloatingIP3:82/ to access third container etc. – Alexandre Fenyo Jul 24 '17 at 12:22