Docker private network individual host access


We’re trying to bring up a DO docker host with 200 containers for testing our agent application and we cannot figure the network part. Let me explain:

  • We are developing an application that is agent-based. An agent is installed on a host and it self-registers with a server to initiate on-going communication.
  • The server then communicates with each host running an agent and send commands.
  • The agents communicate back to the server with a message q
  • Each agent needs its own ip and standard ports with which the server sends commands

I think we can do this with docker Host networking. My thoughts are (forgive my networking ignorance):

  • we give the DO docker host an internal class-b like 172.99.x.x
  • we launch 200+ agent containers in host mode and assign static (or dhcp) addresses to each from the class-b
  • the server is on a remote host that vpns into the DO Docker Host
  • hopefully the server can now “see” the class-b and all of its containers and the containers can communicate with the remote server

I know this is broken… where am i falling down.


Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This question was answered by @evertramos:

@hansen I think some code of how you are trying to do this set up would help us understand better.

I would suggest using Docker Compose with Swarn mode, but about networks… I would suggest you have a very strict way on naming containers and instead using ip:port to connect to your containers, you use sever_name:port to connect to it and let the Docker do the network trick for you.

Here is how you could use Docker Network:

1. Create a Docker Network

docker network create your_network_01

As of Docker Network documentation

2. Use this network in your docker-compose.yml file:

     name: your-network-name

3. Connect any Container to your network

docker network connect your_network_01 your_conteiner_name

As of Docker Network documentation

Hope it helps!

View the original comment