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?
Are these spread across multiple hosts or are they all on the same single host?
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)?
@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
Thanks.
@cjellick any ideas what that is happening?
Thanks for your help.
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.
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/
This hopefully can provide some insight in the issue I’m facing.
Thanks.