Lauch traefik on 2 différents env staging and prod with 2 separate docker-compose

Hi,
I have a issue and I don’t know how to solve it.
On my server I have a staging and prod environnement.
These 2 envs use his own docker-compose with same services but with some changes (command debug,…)
When I fire just one like docker-compose -f staging.yml up -d everything is fine.
When I fire docker-compose -f production.yml some service hasn’t been created because port is already taken like treafik port 443 is already taken by my other Traefik service.
My 2 env are on different networks
Have an idea how to solve this ?
Thank you

If your Traefik instances should run on separate networks (different IPs on host), then make sure to let them listen on the right IPs only, when exposing the ports.

Hi bluepuma77
Thank for your answer what do you mean by that ?

What do you mean by that?

Hi have preprod and production environnement in 2 separate directories like :

www/preprod => with docker-compose -f staging.yml
www/prod => with docker-compose -f production.yml

So your two "networks" are Docker Networks, not physical?

Yes exactly and both have suddomains (preprod.accounts.mydomain.com, accounts.mydomain.com,….)

And I will have another project with Wordpress who have the principal domain my domain.com

Going back to the main question:

  1. Use different hosts
  2. Use different external ports (8080+8443) for Traefik *
  3. Use a single Traefik instance for both envs

I think that are you choices.

*note this will not work with LetsEncrypt httpChallenge or tlsChallenge.

The thing is that I use let’sencscrypt for all of these

That leaves 3 options:

  • Use different hosts
  • Use different external ports (8080+8443) for Traefik with dnsChallenge
  • Use a single Traefik instance for both envs

Thanks bluepuma77,
i will do that :

  • Use a single Traefik instance for both envs
    i will extract traefik service and do a docker-compose.traefik.yml external for all projects.

Last year, I blogged about a setup that we use for "smaller" customer setups. Maybe this will be of help to you: Traefik with multiple Docker networks | bitExpert

Use a single Traefik container.