V2 on Docker Desktop for Mac - Can see dashboard but not WordPress site

I'm fairly new to Docker and Traefik. My initial aim is simply to get WordPress running on my local machine (Mac running Docker Desktop).

All containers start up, and I can see and navigate the dashboard at 127.0.0.1:8080, but visiting 127.0.0.1 gives "404 page not found".

I'm a bit unclear as to whether I need to update my hosts file. I did try that, but it made no difference.

I'm not concerned about SSL/TLS at this point - just trying to crawl before I walk. Here's my docker-compose.yml. Any insights appreciated!

version: '3'

services:
  reverse-proxy:
    # The official v2 Traefik docker image
    image: traefik:v2.2
    # Enables the web UI and tells Traefik to listen to docker
    command: --api.insecure=true --providers.docker
    ports:
      # The HTTP port
      - "80:80"
      - "443:443"
      # The Web UI (enabled by --api.insecure=true)
      - "8080:8080"
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - traefik

  my_db_service:
    image: 'bitnami/mariadb:10.3'
    container_name: my_db_container
    restart: unless-stopped
    env_file: .env
    environment:
      - MARIADB_ROOT_PASSWORD=$my_DB_ROOT_PASSWORD
      - MARIADB_PASSWORD=$my_DB_PASSWORD
      - MARIADB_USER=$my_DB_USER
      - MARIADB_DATABASE=$my_DB
      - ALLOW_EMPTY_PASSWORD=no
    ports:
      - 3306:3306
    volumes:
      - './my_data:/bitnami/mariadb'
    networks:
      - traefik

  my_wp_service:
    image: wordpress:5.4.2-php7.2-fpm-alpine
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.my_wp_container.entrypoints=http"
      - "traefik.http.routers.my_wp_container.rule=Host(`my_wp_container.my.local`, `www.my_wp_container.my.local`)"
      - "traefik.http.services.my_wp_container.loadbalancer.server.port=80"
      - "traefik.docker.network=traefik"
    depends_on:
      - my_db_service
    container_name: my_wp_container
    restart: unless-stopped
    env_file: .env
    environment:
      - WORDPRESS_DB_HOST=my_db_service:3306
      - WORDPRESS_DB_USER=$my_DB_USER
      - WORDPRESS_DB_PASSWORD=$my_DB_PASSWORD
      - WORDPRESS_DB_NAME=$my_DB
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./my_site:/var/www/html

networks:
  traefik:
    external: true

Greetings, welcome to the forums.

This configures Traefik to only route the request when the header Host is present with the values defined in the rule. Browsers do this automatically, but you can test this with curl -H 'Host: my_wp_container.my.local' http://127.0.0.1 You should set up a mask in your hosts file for this to work in your browser.

Also, be sure to declare your entrypoint configuration for Traefik on startup, as seen in this example:

version: "3.3"

services:

  traefik:
    image: "traefik:v2.2"
    container_name: "traefik"
    command:
      #- "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.http.address=:80" # THIS IS IMPORTANT
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

  whoami:
    image: "containous/whoami"
    container_name: "simple-service"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
      - "traefik.http.routers.whoami.entrypoints=http"

If you continue to have issues, please turn on debug logging in Traefik and share the logs of the initialization and when you're trying to access the service so we can help.

1 Like