I have a plumber service and use dockercloud/haproxy for load balancing. I use docker-compose for running my Docker applications:
docker-compose.yml
version: '3'
services:
plumber:
image: registry.code.roche.com/tmbd/tsi-api:latest
command: /plumber.R
volumes:
- ./plumber/plumber.R:/plumber.R
restart: always
lb:
image: 'dockercloud/haproxy:latest'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: always
links:
- plumber
ports:
- 80:80
It works fine with this configuration. Now I have extended my plumber.R
script to communicate with a MongoDB on a remote server to which I established a SSH tunnel with
autossh -M 20000 -L 9999:localhost:27017 <user>@<mongodb-server> -vN -p22
In addition I added the network_mode: host
to the plumber service config in the yml file to make it work.
However, according to here network_mode: host
cannot be mixed with links
and docker-compose gives the following error message:
lb_1 | [ALERT] 208/120346 (9) : parsing [/haproxy.cfg:41] : 'server tsi-api_plumber_1' : could not resolve address 'tsi-api_plumber_1'.
I tried different things but it didn't work. Can someone help with adapting the docker-compose.yml to tell the load balance which service to balance?