TraefikV2 : access container with custom network

Published

I’m using this config (simplified)

version: '3.8'

services:
  mysql:
    container_name: mysql
    image: mysql:8.0
    restart: always
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: test
      MYSQL_USER: symfony
      MYSQL_PASSWORD: symfony
      MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
    ports:
      - 3306:3306
    volumes:
      - db-data:/var/lib/mysql
    networks:
        - dev
    labels:
      traefik.enable: true
      traefik.http.routers.mysql.rule: Host(`mysql.vws.dev`)
      traefik.http.services.mysql.loadbalancer.server.port: 3306

  phpmyadmin:
    image: phpmyadmin
    container_name: phpmyadmin
    restart: always
    depends_on:
        - mysql
    ports:
        - 8090:80
    links:
      - mysql
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
    networks:
        - dev
    labels:
      traefik.enable: true
      traefik.http.routers.phpmyadmin.rule: Host(`phpmyadmin.vws.dev`)
      traefik.http.services.phpmyadmin.loadbalancer.server.port: 80

  reverse-proxy:
    container_name: traefik
    image: traefik:v2.5
    command: --api.insecure=true --providers.docker

    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

volumes:
  db-data:

networks:
  dev:

So the mysql & phpmyadmin containers can communicate together well, but when I try to access phpmyadmin in browser via http://phpmyadmin.vws.dev/ I have a Gateway Timeout.

NOTE : I can acess phpmyadmin just fine when I remove the Network: dev from the phpmyadmin spec, but then when I try to log in it just can’t access the mysql db

Source: Docker Questions

Published
Categorised as docker, docker-compose, traefik Tagged , ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq