# Unstable behaviour in context of docker-compose

**URL:** <https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [October 20, 2020, 10:11am UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254 "2020-10-20T10:11:35Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stef](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/stef/32/3169_2.png) [@Stef](https://community.traefik.io/u/Stef)\
**Post date:** [October 20, 2020, 10:11am UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254/1 "2020-10-20T10:11:35Z")

</div>

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](https://github.com/AmpersandTarski/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).

---

<div class="post-metadata">

**Author:** ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)\
**Post date:** [October 20, 2020, 12:19pm UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254/2 "2020-10-20T12:19:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Stef](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/stef/32/3169_2.png) [@Stef](https://community.traefik.io/u/Stef)\
**Post date:** [October 20, 2020, 1:01pm UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254/3 "2020-10-20T13:01:08Z")

</div>

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.

 ![docker-compose](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/2/25147c7eb73212dd01256e771723d6b5e8e999aa.png)

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

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

```

?

---

<div class="post-metadata">

**Author:** ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)\
**Post date:** [October 20, 2020, 1:03pm UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254/4 "2020-10-20T13:03:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Stef](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/stef/32/3169_2.png) [@Stef](https://community.traefik.io/u/Stef)\
**Post date:** [October 20, 2020, 1:06pm UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254/5 "2020-10-20T13:06:55Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Stef](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/stef/32/3169_2.png) [@Stef](https://community.traefik.io/u/Stef)\
**Post date:** [October 20, 2020, 1:10pm UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254/6 "2020-10-20T13:10:54Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)\
**Post date:** [October 20, 2020, 1:15pm UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254/7 "2020-10-20T13:15:15Z")

</div>

Here:

> **[Traefik Docker Documentation - Traefik](https://doc.traefik.io/traefik/providers/docker/#network)**
>
> Learn how to achieve configuration discovery in Traefik through Docker. Read the technical documentation.

3rd line in [Traefik Docker Configuration Documentation - Traefik](https://doc.traefik.io/traefik/reference/dynamic-configuration/docker/)

> [@Stef](#):
>
> 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

> [@Stef](#):
>
> Sometimes a service comes up, and sometimes it doesn't. It must be some configuration error.

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.

---

<div class="post-metadata">

**Author:** ![Stef](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/stef/32/3169_2.png) [@Stef](https://community.traefik.io/u/Stef)\
**Post date:** [October 20, 2020, 1:42pm UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254/8 "2020-10-20T13:42:07Z")

</div>

I have put in my `traefik.toml`-file:

```auto
# 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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)\
**Post date:** [October 20, 2020, 1:52pm UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254/9 "2020-10-20T13:52:21Z")

</div>

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.

> [@Stef](#):
>
> @cakiwi Thanks again for your invaluable help!

You are welcome

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [October 23, 2020, 1:52pm UTC](https://community.traefik.io/t/unstable-behaviour-in-context-of-docker-compose/8254/10 "2020-10-23T13:52:25Z")

</div>

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