0

I've been studying Docker and all the options available. And I have a VPS with 3 extra static IPs.

The idea is to connect each container to a different IP or maybe add 3 networks with different containers and having each network connected to a different IP. I saw few days ago some tutorials in the internet but I didn't saved them and I can't find them any more.

The IPs are static and were delivered by our ISP (ovh).

So far I tried to connect to IPs using subnet xx.xx.xx.xx/32 (only 1 IP) but it gives me error

PS. I'm newbie at Docker.

Edit

Just tried this code

docker network create \
  --driver=bridge \
  --subnet=AAA.BBB.CCC.DDD/32 \
  --ip-range=AAA.BBB.CCC.DDD/32 \
  --gateway=AAA.BBB.CCC.DDD \
  br0

and I'm getting the current error

Error response from daemon: failed to allocate gateway (AAA.BBB.CCC.DDD): No available addresses on this pool

Also AAA.BBB.CCC.DDD stands for the public IP coming from the ISP

halfer
  • 19,824
  • 17
  • 99
  • 186
Diogo Jesus
  • 318
  • 4
  • 19
  • I believe you would need to assign these IP addresses to the host machine, then forward ports with IPtables. I'm not entirely sure how you would bind the IP addresses to the containers as far as outgoing connections though. – Michael Strobel Apr 03 '17 at 15:04
  • https://docs.docker.com/engine/userguide/networking/work-with-networks/#create-networks – Rao Apr 03 '17 at 16:12
  • @rao but this option olis to be used with a swarm host (multiple servers) in this case i kust want to connect a container or a network to an external IP provided by my ISP – Diogo Jesus Apr 03 '17 at 16:41

1 Answers1

0

An ip adress resolves to a certain place (if your dns server is able to resolve it at all) In this case i'm assuming that the static IP's resolve to the same machine: try to confirm that by running

Host xxx.xxx.xxx

note: use the ipv4 address so omit the slash If the same hostname is returned, my assumption is correct.

On this host, each container will have to expose a port and they can't use the same one. (one port per application)

So you'l either have to navigate to an ip followed by a colon and a port number... Or you can omit the port and have a web server like apache or nginx listen on the default port (80) and configure the routing based on the request received. (then you route it to the individually exposed ports, but this way the client doesn't have to know about those)

Hopefully this gives you some pointers to investigate the options for your goals.

  • Thank you for the suggestion i'll take a look tomorrow morning at work and i will report a feedback – Diogo Jesus Apr 03 '17 at 20:08
  • could you please take a look at my main topic? i did an edit – Diogo Jesus Apr 04 '17 at 07:16
  • I don't have experience with docker networks. However, as far as I am aware they are useful for creating a local networks. In this case you're asking for something different: connect each IP address to another docker container. Try running the host command I mentioned and report back the results please. You should expect a result similar to this: `XXX.XXX.XX.XX.in-addr. domain name pointer ` if the hostname is the same for each IP adress then that means they're already configured to map to the same machine. In this case: install nginx or apache. otherwise I cannot help you – Chris Overgaauw Apr 04 '17 at 14:52