3

So I have the following docker-compose.yml

version: "3.7"

services:
    roundclinic-mysql:
        image: mysql:5.7
        networks:
            - spring-boot-mysql-network
        environment:
            - MYSQL_DATABASE=
            - MYSQL_USER=
            - MYSQL_PASSWORD=
            - MYSQL_ROOT_PASSWORD=
        volumes:
            - ./mysqldata:/var/lib/mysql:rw,delegated
        ports:
            - "3306:3306"
    web-service:
        image: roundclinic/roundclinic:latest
        networks:
            - spring-boot-mysql-network
            - traefik-network
        depends_on:
            - roundclinic-mysql
        ports:
            - 8080:8080
        environment:
            - "SPRING_PROFILES_ACTIVE=dev"
        links:
            - roundclinic-mysql
        labels:
            - "--providers.docker.network=traefik_default"
            - "traefik.enable=true"
            - "traefik.http.routers.roundclinic.rule=Host(`api-dev.roundclinic.app`)"
            - "traefik.http.routers.roundclinic.entrypoints=web"
            - "traefik.http.services.cal.loadbalancer.server.port=8080"
    traefik:
        image: "traefik:v2.2"
        container_name: "traefik"
        command:
            - "--log.level=DEBUG"
            - "--api.insecure=true"
            - "--providers.docker=true"
            - "--providers.docker.exposedbydefault=false"
            - "--entrypoints.web.address=:80"
            - "traefik.docker.network=traefik-network"
        ports:
            - "80:80"
        volumes:
            - "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
    traefik-network:
        driver: bridge
        external: true
    spring-boot-mysql-network:
        driver: bridge
volumes:
    my-db: 

Spring boot starts up fine and can connect to mysql.

When I connect to http://api-dev.roundclinic.app:8080/../ I can hit my application just fine

When I connect to http://api-dev.roundclinic.app/../ I get a gateway timeout. I can see in the traefik logs that it's forwarding the request to what seems to be the correct IP and port, but nothing hits the actual application. I'm not sure what's going on here. Any help?

Cate Daniel
  • 724
  • 2
  • 14
  • 30
  • I'm not able to reproduce the problem with this compose file. Can you please provide me some more data, like what are the db credentials to use this? However I assume the problem is around the port `80`, cause thats a reserved port number, and not default to use it without privileges easily – Mikopet Jul 24 '20 at 12:06
  • [See here](https://stackoverflow.com/a/76646647/9971404) – lonix Jul 09 '23 at 09:06

1 Answers1

2

When accessing port 8080 you are bypassing Traefik and directly access your application, correct?

Generally speaking the Traefik labels look good. Entrypoint, Port and Host are defined, router and service port are present. These are usually all the requirements for Docker-based setups.

One thing that I noticed is that the traefik container uses "traefik.docker.network=traefik-network", but your web app uses: "--providers.docker.network=traefik_default".

I am not sure if traefik_default is something that traefik provides but that mismatch in network names might be the issue.

I can't test if that is the problem but that would be the first thing to check. One way would be to simplify your config but just always using the networks key from docker compose instead of mixing it with labels and arguments.

Gogowitsch
  • 1,181
  • 1
  • 11
  • 32
scepticulous
  • 31
  • 1
  • 4