I am using external network in docker-compose, but Traefik does not seem to understand it and throws the following error:
time="2019-10-30T19:24:25Z" level=warning msg="Could not find network named 'frontend' for container '/qatar_qatarwordpress_1'! Maybe you're missing the project's prefix in the label? Defaulting to first available network." providerName=docker container=qatarwordpress-qatar-d9266c3831f946e6bdfc5f8ee1a765beb6f369a68ab54dc1d312adede2289fa4 serviceName=qatarwordpress-qatar
and when I try to access the site I get a Gateway timeout error.
Traefik docker-compose:
version: '3.7'
services:
traefik:
image: traefik:latest
volumes:
# - ./traefik.toml:/etc/traefik/traefik.toml
- /var/run/docker.sock:/var/run/docker.sock
- "./letsencrypt/:/letsencrypt/"
- "./logs/traefik.log:/traefik.log"
- "./ssl/:/etc/traefik/ssl/"
- "./dyn/:/dyn/"
- "./traefik/:/opt/traefik/"
restart: always
networks:
- frontend
ports:
- "80:80"
- "443:443"
command:
- --api
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--metrics.prometheus=true"
- "--global.sendAnonymousUsage=true"
- "--entryPoints.web.address=:80"
- "--entryPoints.websecure.address=:443"
- "--log.level=DEBUG"
- "--log.filepath=/opt/traefik/traefik.log"
- "--accesslog=true"
- "--accesslog.filepath=/opt/traefik/access.log"
# Lets Encrypt settings:
- "--certificatesresolvers.le.acme.dnschallenge=true"
- "--certificatesresolvers.le.acme.dnschallenge.provider=route53"
- "--certificatesresolvers.le.acme.email=webmaster@XXXXXXXXXX.com"
- "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
environment:
# Lets Encrypt- Route53 DNS Challenge settings
- "AWS_HOSTED_ZONE_ID=XXXXXXXXX"
- "AWS_ACCESS_KEY_ID=XXXXXXXXXX"
- "AWS_SECRET_ACCESS_KEY=XXXXXXXXXX"
labels:
# global redirect to https
- "traefik.http.routers.redirs.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.redirs.entrypoints=web"
- "traefik.http.routers.redirs.middlewares=redirect-to-https"
# middleware redirect
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
# dashboard
- "traefik.http.routers.traefik.rule=Host(`traefik.XXXXX.com`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.tls.certresolver=le"
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.routers.traefik.middlewares=admin"
- "traefik.http.middlewares.admin.basicauth.users=admin:XXXXXXXXXX"
whoami:
image: "containous/whoami"
container_name: "simple-service"
networks:
- frontend
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`whoami.XXXXXXXXXX.com`)"
- "traefik.http.routers.whoami.entrypoints=websecure"
- "traefik.http.routers.whoami.tls.certresolver=le"
- "traefik.http.routers.whoami.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=myuser:XXXXXXXXXX"
networks:
frontend:
external:
name: traefik-proxy
Wordpress docker-compose:
version: '3.7'
services:
#Database
db:
image: mysql:latest
volumes:
- ./db_data:/var/lib/mysql
restart: always
networks:
- backend
command: mysqld --default_authentication_plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
#WordPress
qatarwordpress:
depends_on:
- db
image: wordpress:latest
restart: always
networks:
- frontend
- backend
volumes:
- ./html:/var/www/html
labels:
- "traefik.enable=true"
- "traefik.docker.network=frontend"
- "traefik.http.routers.wordpress.rule=Host(`qatar.XXXXXXXXXX.com`)"
- "traefik.http.routers.wordpress.entrypoints=websecure"
- "traefik.http.routers.wordpress.tls.certresolver=le"
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
backend:
frontend:
external:
name: traefik-proxy
What am I doing wrong?