Unstable behaviour in context of docker-compose

I have abandoned HAproxy and traded it for Traefik because I need the proxy to route services that are created and removed dynamically. I got my system (called RAP) up and running. However, I cannot seem to get stable behavior. Sometimes a service comes up, and sometimes it doesn't. It must be some configuration error. I have now spent days to find the mistake and getting desperate. Is anyone in the community willing to "look over my shoulder", take a peek and help me out? The traefik.toml and docker-compose.yml files are in the repo (see hyperlink above).

HI @Stef

Some of your containers have multiple networks, you have to specify to traefik which network to use.
You can specify a default with the provider option: providers.docker.network or on a container/router basis with traefik.docker.network

Without a better problem statement that is the best I can surmise.

Hi @Cakiwi, thanks so much for taking the time to look into this. Indeed I am using multiple networks. The following picture shows the structure of RAP. Solid arrows point to networks. (the dotted arrows indicate volume use and dependencies). As you can see, the Traefik service uses one network only (being proxy), which has been declared external.

I am puzzled by your suggestion. Do you suggest that in my traefik.toml file I add:

[providers.docker.network]
  Default: "proxy"

?

That would be the easiest option. But as I mentioned there are two ways to do it.

@cakiwi
I guess the second way is "on a container/router basis with traefik.docker.network".

That doesn't ring any bells. Can you point to a manual page or provide a little more info so I can figure it out? In the meantime, let me test the first way. If it works I'm quite happy already.

And you are quite right in stating that my problem statement is lacking. Since I'm not very familiar with Traefik, I find it extremely hard to diagnose my problem. Especially since I cannot reproduce when services are made available and when they are not, it is undoable to figure out a root cause of this problem. I am curious as to what is going on, but I guess I'll have to read more about Traefik to stand a chance...

Here:

3rd line in Traefik Docker Configuration Documentation - Traefik

Just a little extra info, as this is just further from "it's not working" What are you experiencing. What happens when you access the service. HTTP 404,502,500 etc.
Any relevant information in the traefik log.

I have put in my traefik.toml-file:

# Enable Docker configuration backend
[providers.docker]
  network = "proxy"
  exposedByDefault = true

All services are now accessible, so this seems to do the trick.
After having established that all services are now accessible, the Traefik log file shows:

Attaching to traefik
traefik                    | time="2020-10-20T13:31:45Z" level=info msg="Configuration loaded from file: /etc/traefik/traefik.toml"

So that looks good. I still have no clue about the nature of this problem. But I will definitely go back to the manual to find out why this works (assuming it does...). And learn some more about Traefik... In the meantime I will have to get some mileage with testing and running this application to see whether it is stable now.

@cakiwi Thanks again for your invaluable help!

The docker provider will discover the addresses of the container, as the container has more than one network traefik will pick one of them. If traefik is only on one of those networks the other address will not be reachable. I think the first network returned is the one used, but this is not deterministic so can result in the route/service intermittently working.

By identifying which docker network to use for the container you eliminate this problem as docker can filter which address to use.

You are welcome

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.