Docker-compose with multiple networks and reverse proxy fails: ambiguous container id

This relates to the docker-compose repo, current HEAD. docker-compose is version 1.21.0, docker is version 18.09.1, build 4c52b90.

I’m running ttrss on a server where I run multiple services behind a traefik reverse proxy. The default method to connect a service to traefik is to have a external docker network, in my case called traefik_proxy, to which the web service (in my case web-nginx from ttrrs) is connected. The actual ttrss services are running in a ttrss_backend network. web-nginx is connected to both the proxy and the backend. Also, I have multiple other web servers connected to the traefik_proxy network.

When running the unchanged docker-compose.yml, nginx would give a cgi fastpath error, indicating a refused connection. I found that web-nginx tries to resolve the name app (as the service is called in the yml). This name is ambiguous in my setup, since it exists in ttrss_backend as ttrss_app_1, and in traefik_proxy as static_app_1 (serving a static website). In my case, app was resolved as static_app_1, not ttrss_app_1.

I fixed this in the following way:

  • gave app the attribute container_name: ttrss_app
  • edited web-nginx/nginx.confand replaced all occurences of app with ttrss_app

Since the problem and the workaround is specific to reverse-proxy setups with multiple docker networks, it probably wouldn’t make sense to adopt this as a config. May I suggest to add something about this to the readme?

the readme says that you shouldn’t rename the containers. what else would you like me to add?

Of course, you can keep everything as it is. If not renaming the containers, then setups like this are not going to work. Your software, your choice.