# Multi-container stack

**URL:** <https://forums.suse.com/t/multi-container-stack/10676>\
**Category:** Rancher 1.x\
**Created:** [June 6, 2018, 1:39pm UTC](https://forums.suse.com/t/multi-container-stack/10676 "2018-06-06T13:39:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigfrid](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sigfrid/32/2205_2.png) [@sigfrid](https://forums.suse.com/u/sigfrid)\
**Post date:** [June 6, 2018, 1:39pm UTC](https://forums.suse.com/t/multi-container-stack/10676/1 "2018-06-06T13:39:19Z")

</div>

I have a stack made of 3 containers (db, app, and proxy).  
When I run it via docker-compose everything works. However, when I try to start it using rancher CLI (`rancher-compose -p newapp up`) the containers don’t see each other.

Here the significant part of my `docker-compose.yml`

```
version: '2'

services:
  db:
    image: sigfrid/postgres
    ports:
      - 5432:5432
    network_mode: bridge
    labels:
      io.rancher.scheduler.affinity:host_label: app=newapp

  app:
    image: sigfrid/newapp
    ports:
      - 3000:3000
    links:
      - db
    depends_on:
      - db
    network_mode: bridge
    labels:
      io.rancher.scheduler.affinity:host_label: app=newapp

  proxy:
    image: sigfrid/nginx
      - 80:80
      - 443:443
    links:
      - app
    depends_on:
      - app
    network_mode: bridge
    labels:
      io.rancher.scheduler.affinity:host_label: app=newapp

```

Am I missing anything here?

---

<div class="post-metadata">

**Author:** ![cjellick](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/cjellick/32/2876_2.png) [@cjellick](https://forums.suse.com/u/cjellick)\
**Post date:** [June 6, 2018, 3:42pm UTC](https://forums.suse.com/t/multi-container-stack/10676/2 "2018-06-06T15:42:28Z")

</div>

Are these spread across multiple hosts or are they all on the same single host?

---

<div class="post-metadata">

**Author:** ![sigfrid](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sigfrid/32/2205_2.png) [@sigfrid](https://forums.suse.com/u/sigfrid)\
**Post date:** [June 6, 2018, 4:35pm UTC](https://forums.suse.com/t/multi-container-stack/10676/3 "2018-06-06T16:35:13Z")

</div>

Same host, see labels.

Thanks

---

<div class="post-metadata">

**Author:** ![cjellick](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/cjellick/32/2876_2.png) [@cjellick](https://forums.suse.com/u/cjellick)\
**Post date:** [June 6, 2018, 5:17pm UTC](https://forums.suse.com/t/multi-container-stack/10676/4 "2018-06-06T17:17:42Z")

</div>

Saw the labels…more than one host could have that label, thats why I wanted to clarify.

Can you ellaborate on “dont see each other”? How are they trying to see each other.  
Does it work if you drop `network_mode: bridge` (which would cause it to use the rancher overlay network)?

---

<div class="post-metadata">

**Author:** ![sigfrid](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sigfrid/32/2205_2.png) [@sigfrid](https://forums.suse.com/u/sigfrid)\
**Post date:** [June 7, 2018, 9:35am UTC](https://forums.suse.com/t/multi-container-stack/10676/5 "2018-06-07T09:35:13Z")

</div>

@cjellick you are right, I could have multiple hosts with the same label but I don’t. There is only 1 host with the `newapp` label.

the two errors I get are the following.

> thx-app-1 | 2018-06-07T09:22:52.063050743Z PG::ConnectionBad: could not translate host name “db” to address: Name or service not known
> 
> th-proxy-1 | 2018-06-07T08:45:07.965236834Z 2018/06/07 08:45:07 [emerg] 1#1: host not found in upstream “app” in /etc/nginx/conf.d/default.conf:38

if I drop `network_mode: bridge` nothing starts

> INFO[0000] Existing volume template found for postgres-data-volume  
> INFO[0000] [0/3] [db]: Creating  
> INFO[0000] Creating service db  
> INFO[0001] [0/3] [db]: Created  
> INFO[0001] [0/3] [app]: Creating  
> INFO[0001] Creating service app  
> INFO[0002] [0/3] [app]: Created  
> INFO[0002] [0/3] [proxy]: Creating  
> INFO[0002] Creating service proxy  
> INFO[0002] [0/3] [proxy]: Created  
> INFO[0002] Existing volume template found for postgres-data-volume  
> INFO[0002] [0/3] [db]: Starting

until it times out.

I have also tried `io.rancher.container.network: true` but it seems this is ignored. See [Docker compose and managed network](http://forums.suse.com/t/docker-compose-and-managed-network/10665)

Thanks.

---

<div class="post-metadata">

**Author:** ![sigfrid](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sigfrid/32/2205_2.png) [@sigfrid](https://forums.suse.com/u/sigfrid)\
**Post date:** [June 11, 2018, 9:55am UTC](https://forums.suse.com/t/multi-container-stack/10676/6 "2018-06-11T09:55:26Z")

</div>

@cjellick any ideas what that is happening?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![vainkop](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vainkop/32/3190_2.png) [@vainkop](https://forums.suse.com/u/vainkop)\
**Post date:** [June 11, 2018, 2:45pm UTC](https://forums.suse.com/t/multi-container-stack/10676/7 "2018-06-11T14:45:33Z")

</div>

Your config seems pretty simple, so try to create your stack from UI with default network option offered (not host) & then download docker & rancher composes to see how they differ from yours.

---

<div class="post-metadata">

**Author:** ![sigfrid](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sigfrid/32/2205_2.png) [@sigfrid](https://forums.suse.com/u/sigfrid)\
**Post date:** [June 12, 2018, 8:50am UTC](https://forums.suse.com/t/multi-container-stack/10676/9 "2018-06-12T08:50:49Z")

</div>

If I try to create the stack from UI I get an error while the first container is trying to activate (Timeout getting IP address). Please note my docker0 bridge has been customized (bip=192.168.134.1/24) due to a IP conflict within my LAN. [https://docs.docker.com/v17.09/engine/userguide/networking/default\_network/custom-docker0/](https://docs.docker.com/v17.09/engine/userguide/networking/default_network/custom-docker0/)  
This hopefully can provide some insight in the issue I’m facing.

Thanks.
