Gateway timeout when traefik and app in separate docker-compose files

Hi, I am trying to use separate docker-compose.yml files for traefik and app. But get gateway timout error for the app.

My traefik docker-compose file:

version: '3.3'
services:
  reverse-proxy:
    image: traefik:v2.2
    ports:
    # The HTTP port
    - "80:80"
    # The Web UI (enabled by --api.insecure=true)
    - "8080:8080" # Enables the web UI and tells Traefik to listen to docker
    - "8443:8443"
    - "443:443"
    container_name: traefik
    restart: unless-stopped
    command:
      - --api
      - --api.insecure=true
      - --providers.docker
      - --providers.docker.exposedbydefault=false
      - --log.level=INFO
      - --api.dashboard=true
      - --entrypoints.websecure.address=:443
      - --entrypoints.web.address=:80
      - --entrypoints.jitsi.address=:8443
      # - --certificatesResolvers.myresolver.acme.tlschallenge=true # <== Enable TLS-ALPN-01 to generate and renew ACME certs
      -`  [ `--certificatesResolvers.myresolver.acme.email=asdasasdas@gmail.com` ](mailto:--certificatesResolvers.myresolver.acme.email=levas.cernovas@gmail.com)  `# <== Setting email for certs
      - --certificatesResolvers.myresolver.acme.storage=/letsencrypt/acme.json # <== Defining acme file to store cert information
      - --certificatesResolvers.myresolver.acme.httpChallenge.entryPoint=web
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock
      - letsencrypt:/letsencrypt/
    networks:
      - web
    labels:
      traefik.enable: true
      traefik.http.routers.http_catchall.rule: hostregexp(` {host:.+}`)
      traefik.http.routers.http_catchall.entrypoints: web
      traefik.http.routers.http_catchall.tls: true
      #Dashboard
      traefik.http.routers.traefik.rule: host(` dashboard.docker.localhost`)
      traefik.http.routers.traefik.entrypoints: web
      traefik.http.routers.traefik.tls: true
      traefik.http.routers.traefik.tls.certresolver: myresolver
      traefik.http.routers.service: api@internal

volumes:
  letsencrypt:
networks:
  web:

My service docker-compose file:

version: '2'
  services:
    whoami:
      image: containous/whoami
      labels:
        traefik.enable: true
        traefik.http.routers.whoami.rule: host(` whoami.docker.localhost`)
        traefik.http.routers.whoami.entrypoints: web
    networks:
    - web
networks:
  web:
    external: true

When you run compose it will create your items in a namespace(project). By default is is the name of the CWD(Current Working Directory).

If you run a docker network ls you will see this network as projectname_web .

You can resolve this in a few ways.

  • Run docker-compose with a -p name flag to put them in the same namespace.
  • Create your web network with a name: web option to explicitly name it
  • Create the network yourself and use external: true on both compose files.
1 Like