Answers: <p>The classic answer to balancing load is, of course, a load balancer. There are many different methods of doing this, but we're interested in ones that work well with dynamic containers.</p>
  
  <p>This is one of the things an orchestration layer will address. In Kubernetes, for instance, you would create a Tensor Flow <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">service</a>, and scale it to however many pods you need (or use autoscaling!). Kubernetes then provides an ip for the service that kube-proxy load balances across the pods.</p>
  
  <p>There are also service mesh options that replace this layer and perform a similar function.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-12-18T07:47:12.017Z
Answers: 2018-12-18T07:47:12.017Z
Answers: Xiong Chiamiov
Answers: <p>You should assign a specific port to any containers.<br>
  For this configuration you can use <code>docker-compose</code> file such as following example:</p>
  
  <pre><code>version: '3'
  
  services:
    TensorFlow-1:
        image: gcr.io/tensorflow/tensorflow:latest-gpu
        container_name: first-tensor
        ports:
          - "9001:8888"
  
    TensorFlow-2:
        image: gcr.io/tensorflow/tensorflow:latest-gpu
        container_name: second-tensor
        ports:
          - "9002:8888"
  </code></pre>
  
  <p>Then in the <code>docker-compose.yml</code> path, on command-line do it:   </p>
  
  <pre><code>sudo docker-compose up
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>sudo docker-compose up -d  
  </code></pre>
  
  <p><strong>NOTE</strong>: <code>-d</code> option is for run above command in the background.    </p>
  
  <p>Finally you have two tensorflow containers with <code>9001</code> and <code>9002</code> ports.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-06-21T19:03:14.430Z
Answers: I fail to see how you'd tell the 4 nginx container to spread their loads on then 2 tensor flow ones, and that sound tedious to scale out of this simple example
Answers: Tensibai
Answers: CC BY-SA 4.0
Answers: 2018-06-21T20:16:35.617Z
Answers: @Tensibai On this answer, I create two containers of tensorflow as a simple exaplme, you can create four tensorflow container with scale of that, using `9001`, `9002`, `9003`, `9004` ports.
Answers: Benyamin Jafari
Answers: CC BY-SA 4.0
Answers: 2018-06-22T06:20:59.590Z
Answers: And what about how to use it in the other containers?
Answers: Tensibai
Answers: CC BY-SA 4.0
Answers: 2018-06-22T19:34:10.713Z
Answers: @Tensibai The docker have an IP, and each of containers have an specific IP. Tensorflow container port  on this example is `8888` and we have four tensorflow instance (container) with exterior ports (`9001`, `9002`, `9003`, `9004`). If you want use each of tensorflow container must be use `<tesnorflow-containers-IP>:8888` or use `<docker-IP>:900X`
Answers: Benyamin Jafari
Answers: CC BY-SA 4.0
Answers: 2018-06-22T20:19:04.980Z
Answers: I'll stop trying to make you edit this answer into something usable, you're answering aside of the question which has very few value in my eyes as it's a basic container orchestration problem you won't solve with statically typed names/addresses in the docker file when you're up to 50 containers and more
Answers: Tensibai
Answers: CC BY-SA 4.0
Answers: 2018-06-21T15:48:58.100Z
Answers: 2018-06-28T12:06:17.800Z
Answers: 2018-06-28T12:06:17.800Z
Answers: Benyamin Jafari
Body: <p>I have two containers (Docker):</p>
  
  <ul>
  <li>TensorFlow container</li>
  <li>NodeJS container used as a frontend to the TensorFlow container.</li>
  </ul>
  
  <p>Both containers have TCP listeners on a port specified using environment variables.</p>
  
  <p>If I want to scale the NodeJS and TensorFlow containers, for example 2 instances of NodeJS and 4 instances of TensorFlow, what are my options for connecting them to evenly spread the load across the 4 instances of TensorFlow?</p>
  
  <p>Currently I'm using the TensorFlow container name inside the NodeJS container, but I'm pretty sure that would only take advantage of a single TensorFlow container... Or??</p>
  
Comments: CC BY-SA 4.0
Comments: 2018-09-26T14:46:53.133Z
Comments: http://superuser.openstack.org/articles/run-load-balanced-service-docker-containers-openstack/
Comments: Jiri Klouda
Tags: <docker><containers>
Title: What methods are available for connecting many-to-many containers?
UserDisplayName: Woodgnome
ThreadText: # What methods are available for connecting many-to-many containers?
  
  (Asked by: username_0 on 2018-06-21)
  
  I have two containers (Docker):
  
  * TensorFlow container
  * NodeJS container used as a frontend to the TensorFlow container.
  
  Both containers have TCP listeners on a port specified using environment variables.
  
  If I want to scale the NodeJS and TensorFlow containers, for example 2 instances of NodeJS and 4 instances of TensorFlow, what are my options for connecting them to evenly spread the load across the 4 instances of TensorFlow?
  
  Currently I'm using the TensorFlow container name inside the NodeJS container, but I'm pretty sure that would only take advantage of a single TensorFlow container... Or??
  
  **Tags:** docker, containers
  
  > **Comments:**
  > **username_1**: http://superuser.openstack.org/articles/run-load-balanced-service-docker-containers-openstack/  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-12-18. Score: 1
  
  The classic answer to balancing load is, of course, a load balancer. There are many different methods of doing this, but we're interested in ones that work well with dynamic containers.
  
  This is one of the things an orchestration layer will address. In Kubernetes, for instance, you would create a Tensor Flow [service](https://kubernetes.io/docs/concepts/services-networking/service/), and scale it to however many pods you need (or use autoscaling!). Kubernetes then provides an ip for the service that kube-proxy load balances across the pods.
  
  There are also service mesh options that replace this layer and perform a similar function.
  
  
  ---
  
  ### Answer by username_3 on 2018-06-21. Score: -1
  
  You should assign a specific port to any containers.  
  For this configuration you can use `docker-compose` file such as following example:
  
  ```
  version: '3'
  
  services:
    TensorFlow-1:
        image: gcr.io/tensorflow/tensorflow:latest-gpu
        container_name: first-tensor
        ports:
          - "9001:8888"
  
    TensorFlow-2:
        image: gcr.io/tensorflow/tensorflow:latest-gpu
        container_name: second-tensor
        ports:
          - "9002:8888"
  
  ```
  
  Then in the `docker-compose.yml` path, on command-line do it:
  
  ```
  sudo docker-compose up
  
  ```
  
  Or
  
  ```
  sudo docker-compose up -d  
  
  ```
  
  **NOTE**: `-d` option is for run above command in the background.
  
  Finally you have two tensorflow containers with `9001` and `9002` ports.
  
  > **Comments:**
  > **username_4**: I fail to see how you'd tell the 4 nginx container to spread their loads on then 2 tensor flow ones, and that sound tedious to scale out of this simple example  
  > **username_3**: @username_4 On this answer, I create two containers of tensorflow as a simple exaplme, you can create four tensorflow container with scale of that, using `9001`, `9002`, `9003`, `9004` ports.  
  > **username_4**: And what about how to use it in the other containers?  
  > **username_3**: @username_4 The docker have an IP, and each of containers have an specific IP. Tensorflow container port  on this example is `8888` and we have four tensorflow instance (container) with exterior ports (`9001`, `9002`, `9003`, `9004`). If you want use each of tensorflow container must be use `<tesnorflow-containers-IP>:8888` or use `<docker-IP>:900X`  
  > **username_4**: I'll stop trying to make you edit this answer into something usable, you're answering aside of the question which has very few value in my eyes as it's a basic container orchestration problem you won't solve with statically typed names/addresses in the docker file when you're up to 50 containers and more  
  
  ---
  
  