Cannot get Adminer to work on Traefik v2

Hi. I am trying to figure out how to get seperate websites with their own docker-compose file to work on my server. The domain example.com points to my server. The WordPress blog is running fine (except for the fact that there is no database, because I want to manage that using Adminer). I've tried running docker-compose up -d for both docker-compose.yml files in ~/docker/traefik and ~/docker/sites/example but example.com:4444 does not work. What am I doing wrong? All online v2 examples just show the Adminer settings that I've used. Am I missing something? I've also tried 8080:8080 but that did not work either. Is it bad that both Adminer and the Traefik dashboard are using port 8080? Configuration files are below.

Thanks in advance!

'- docker
   '- sites
      '- example
         '- docker-compose.yml
         '- .env
         '- html
      '- site1
      '- site2
      ...
   '- traefik
      '- acme.json
      '- config.yml
      '- docker-compose.yml
      '- traefik.yml

~/docker/traefik/traefik.yml

api:
  dashboard: true
  debug: false

entryPoints:
  example-web:
    address: ":80"
  example-web-secure:
    address: ":443"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
  file:
    filename: /config.yml

certificatesResolvers:
  http:
    acme:
      caServer: https://acme-staging-v02.api.letsencrypt.org/directory
      email: <EMAIL HERE>
      storage: acme.json
      httpChallenge:
        entryPoint: example-web

~/docker/traefik/config.yml

http:
  middlewares:
    https-redirect:
      redirectScheme:
        scheme: https

~/docker/traefik/docker-compose.yml

version: '3'

services:
  traefik:
    image: traefik:v2.0
    container_name: traefik
    restart: always
    security_opt:
      - no-new-privileges:true
    networks:
      - traefik-network
    ports:
      - 80:80
      - 443:443
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./traefik.yml:/traefik.yml:ro
      - ./acme.json:/acme.json
      - ./config.yml:/config.yml:ro
    labels:
      # Enable the service
      - "traefik.enable=true"

      # Set initial entry point for Traefik and define host
      - "traefik.http.routers.traefik.entrypoints=example-web"
      - "traefik.http.routers.traefik.rule=Host(`traefik.example.com`)"

      # Define the middlewares
      - "traefik.http.middlewares.example-auth.basicauth.users=<CREDENTIALS HERE>"
      - "traefik.http.middlewares.example-redirect.redirectscheme.scheme=https"
      
      # Set the redirection middleware
      - "traefik.http.routers.traefik.middlewares=example-redirect"
      
      # Set entry points for HTTPS and define host
      - "traefik.http.routers.traefik-secure.entrypoints=example-web-secure"
      - "traefik.http.routers.traefik-secure.rule=Host(`traefik.example.com`)"
      
      # Set the authentication middleware
      - "traefik.http.routers.traefik-secure.middlewares=example-auth"
      
      # Set the certification settings
      - "traefik.http.routers.traefik-secure.tls=true"
      - "traefik.http.routers.traefik-secure.tls.certresolver=http"
      
      # Dashboard settings
      - "traefik.http.routers.traefik-secure.service=api@internal"
      - "traefik.http.services.traefik.loadbalancer.server.port=8080"

networks:
  traefik-network:
    external: true

/docker/sites/example/docker-compose.yml

version: '3'

services:
  database:
    image: mariadb:10.4
    volumes:
      - db-data:/var/lib/mysql
    networks:
      - traefik-network
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${WP_DB_ROOT_PASSWORD}
      MYSQL_DATABASE: ${WP_DB_NAME}
      MYSQL_USER: ${WP_DB_USER}
      MYSQL_PASSWORD: ${WP_DB_PASSWORD}

  wordpress:
    depends_on:
      - database
    image: wordpress:5.3-php7.4
    volumes:
      - ./html:/var/www/html
    networks:
      - traefik-network
    restart: always
    labels:
      # Enable in Traefik dashboard
      - "traefik.enable=true"

      # Redirection
      - "traefik.http.middlewares.example-redirect.redirectscheme.scheme=https"

      # HTTP
      - "traefik.http.routers.${WEBSITE_NAME}.entrypoints=example-web"
      - "traefik.http.routers.${WEBSITE_NAME}.rule=Host(${WEBSITE_DOMAINS})"
      - "traefik.http.routers.${WEBSITE_NAME}.middlewares=example-redirect"

      # HTTPS
      - "traefik.http.routers.${WEBSITE_NAME}-secure.entrypoints=example-web-secure"
      - "traefik.http.routers.${WEBSITE_NAME}-secure.rule=Host(${WEBSITE_DOMAINS})"
      - "traefik.http.routers.${WEBSITE_NAME}-secure.tls=true"
      - "traefik.http.routers.${WEBSITE_NAME}-secure.tls.certresolver=http"
    environment:
      WORDPRESS_DB_HOST: database:3306
      WORDPRESS_DB_NAME: ${WP_DB_NAME}
      WORDPRESS_DB_USER: ${WP_DB_USER}
      WORDPRESS_DB_PASSWORD: ${WP_DB_PASSWORD}

  adminer:
    depends_on:
      - database
    image: adminer:latest
    restart: always
    networks:
      - traefik-network
    ports:
      - 4444:8080
    labels:
      - "traefik.enable=true"

volumes:
  db-data: {}

networks:
  traefik-network:
    external: true

~/docker/sites/example/.env

WEBSITE_NAME=example
WEBSITE_DOMAINS=`example.com`, `www.example.com`

WP_DB_ROOT_PASSWORD=test
WP_DB_NAME=test
WP_DB_USER=test
WP_DB_PASSWORD=test

From what I understand, you shouldn’t be exposing ports for your “adminer” service.

First off, I would move your database and adminer to an internal network since they don’t access the outside world (WAN).

Instead, add labels to your adminer for traefik with your subdomain and add a loadbalancer label to Adminer’s internal port. (I actually don’t know how to point domain:port to a container. can’t really help you there since i use a subdomain for all my services... but i’m sure using a port should be easy)

also, maybe consider cleaning up your env files. you can use the “env_file” key in docker-compose and have your variables there per service instead of defining them twice.

I’ll edit my posts later when I have more time and provide my configs that show the Adminer UI and allows me to manage databases, maybe it’ll help you a bit, even if my config isn’t perfect :slight_smile: