I an connect inside container but get 'gateway timeout' from outside it

hi,

behind a traefik container i have a running wordpress server but when i want to connect another similar container all i get is a 'gateway timeout'


   wget -O -S - http://gaulix.example.com

nevertheless, the most curious thing is that if i 'login' into the traefik container i can browse the second container:

  docker exec -it traefik /bin/sh
  wget -S -O - http://172.30.0.4

the network configuration is:

$ docker network inspect red_traefik | jq |egrep 'Name|IPv4Address'
    "Name": "red_traefik",
        "Name": "gaulixv2_php7410gaulix_1",
        "IPv4Address": "172.30.0.4/16",
        "Name": "traefik",
        "IPv4Address": "172.30.0.2/16",
        "Name": "traefik-wp3_wp_prueba_1",
        "IPv4Address": "172.30.0.3/16",

and the individuals docker-compose.yml files are:

8<----------------------------------------------------------------------
docker-compose-traefik.yml

version: '3.3'

networks:
  red_traefik:
    external: true

services:
  traefik:
    image: traefik:v2.6.1
    container_name: "traefik"
    restart: always
    command:
      - "--log.level=DEBUG"
      - "--api.dashboard=true"
      - "--entrypoints.web_80.address=:80"
      - "--entrypoints.web_443.address=:443"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--certificatesresolvers.midesafiotls.acme.httpchallenge=true"
      - "--certificatesresolvers.midesafiotls.acme.httpchallenge.entrypoint=web_80"
      - "--certificatesresolvers.midesafiotls.acme.email=fulano@example.com"
      - "--certificatesresolvers.midesafiotls.acme.storage=/letsencrypt/acme.json"

    ports:
      - "80:80"
      - "443:443"
      - "8888:8080"
    labels:
      - "traefik.enable=true"
      # Dashboard
      - "traefik.http.routers.traefik.rule=(Host(`maquina_docker.example.com`) && (PathPrefix(`/tr-api`) || PathPrefix(`/tr-dashboard`)))"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.tls.certresolver=midesafiotls"
      - "traefik.http.routers.traefik.entrypoints=web_443"
      - "traefik.http.routers.traefik.middlewares=dashboardauth"
      - "traefik.http.middlewares.dashboardauth.basicauth.users=usr:$$apr1$$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      # HTTPS Redirect
      - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.entrypoints=web_80"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https@docker"
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./datos_letsencrypt:/letsencrypt
    networks:
      - red_traefik

8<----------------------------------------------------------------------
docker-compose-running_wordpress.yml

version: '3.3'

networks:
  # enable connection with Traefik
  red_traefik:
    external: true
  # network for the app
  red_interna:

services:

  wp_prueba:
    depends_on:
      - db_prueba
    image: wordpress:latest
    restart: always
    environment:
      WORDPRESS_DB_HOST: db_prueba:3306
      WORDPRESS_DB_USER: usr_prueba
      WORDPRESS_DB_PASSWORD: xxxxxxxxxxxxxxxxxxx
      WORDPRESS_DB_NAME: prueba

    networks:
      - red_traefik
      - red_interna

    volumes:
      - ./datos_prueba:/var/www/html

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.wp_prueba.entrypoints=web_80"
      - "traefik.http.routers.wp_prueba.rule=Host(`prueba.example.com`)"

      - "traefik.http.routers.wp_prueba.entrypoints=web_443"
      - "traefik.http.routers.wp_prueba.rule=Host(`prueba.example.com`)"
      - "traefik.http.routers.wp_prueba.tls.certresolver=midesafiotls"

      - "traefik.http.services.wp_prueba.loadbalancer.server.port=80"


  db_prueba:
    image: mysql:5.7
    volumes:
      - ${PWD}/datos_db_wp_prueba:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: prueba
      MYSQL_USER: usr_prueba
      MYSQL_PASSWORD: xxxxxxxxxxxxxxxxxxx
    networks:
      - red_interna

8<----------------------------------------------------------------------
docker-compose-second_problematic_container.yml

version: '3.3'

networks:
  red_traefik:
    external: true
  red_interna:

services:

  php7410gaulix:
    image: php7410gaulix
    volumes:
      - ./html:/var/www/html
      - ./datos_tmp:/tmp

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.gaulix_80.entrypoints=web_80"
      - "traefik.http.routers.gaulix_80.rule=Host(`gaulix.example.com`)"

      - "traefik.http.routers.gaulix_443.entrypoints=web_443"
      - "traefik.http.routers.gaulix_443.rule=Host(`gaulix.example.com`)"
      - "traefik.http.routers.gaulix_443.tls.certresolver=midesafiotls"

    networks:
      - red_traefik
      - red_interna

  mariadb-gaulix:
    image: mariadb:10
    command: --character-set-server=utf8mb4  --collation-server=utf8mb4_unicode_ci

    volumes:
      - ./mariadb_datos:/var/lib/mysql
    restart: always
    networks:
      - red_interna

any help would be appreciated

just for completeness, i forgot to mention that the traefik logs showed up the message:

traefik | time="2022-03-01T18:54:53Z" level=debug msg="'504 Gateway Timeout' caused by: dial tcp 172.23.0.3:80: i/o timeout"

and that network address (172.23.x.x) really belonged to the internal network 'red_interna'

anyway, in the end, i have my second container running behind traefik and the problem i had it was that in a mental lapse, i have restarted it with

docker -f docker-compose-XXXX.yml restart

and instead shoud have exuted:

  docker -f docker-compose-XXXX.yml stop
  docker -f docker-compose-XXXX.yml up -d

As your service is on multiple networks you will have to configure traefik which one to use.

- "traefik.docker.network=red_traefik"

1 Like

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