Cannot start traefik

I cannot seem to get traefik to start.
This instance is on a new server build of Ubuntu 18.0.4, running docker.

My config files:

docker-compose.yml:

version: '3'

services:
  traefik:
    image: traefik:v2.0
    container_name: traefik
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./data/traefik.yml:/traefik.yml:ro
      - ./data/acme.json:/acme.json
      - ./data/config.yml:/config.yml:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.entrypoints=http"
      - "traefik.http.routers.traefik.rule=Host(`external.domain.com`)"
      - "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
      - "traefik.http.routers.traefik-secure.entrypoints=https"
      - "traefik.http.routers.traefik-secure.rule=Host(`external.domain.com`)"
      - "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
      - "traefik.http.routers.traefik-secure.tls=true"
      - "traefik.http.routers.traefik-secure.tls.certresolver=http"
      - "traefik.http.routers.traefik-secure.service=api@internal"

networks:
  proxy:
    external: true

traefik.yml:

api:
  dashboard: true

entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

certificatesResolvers:
  http:
    acme:
      email: user@domain.com
      storage: acme.json
      httpChallenge:
        entryPoint: http

The error I get is:

traefik    | 2019/11/20 08:32:04 command traefik error: read /traefik.yml: is a directory
traefik exited with code 1

Any idea where I am going wrong?

Thanks

Docker volumes must be full path:

volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "/home/jlorenzo/traefik2/dyn.yml:/tmp/dyn.yml"

Docker volumes don't need to be full path.

But the path ./data/traefik.yml must be checked.

Ok, but I found a lot of troubles with relative path. Full path avoid all these problems.

These are my paths:

traefikadmin@traefik:~/traefik$ ls -lh
total 12K
-rw------- 1 root root    0 Nov 19 08:51 acme.json
drwxr-xr-x 4 root root 4.0K Nov 19 09:41 data
-rw-r--r-- 1 root root 1.3K Nov 20 08:31 docker-compose.yml
-rw-r--r-- 1 root root  388 Nov 19 09:34 traefik.yml
traefikadmin@traefik:~/traefik/data$ ls -lh
total 12K
drwxr-xr-x 2 root root 4.0K Nov 19 09:35 acme.json
-rw-r--r-- 1 root root   86 Nov 19 09:36 config.yml
drwxr-xr-x 2 root root 4.0K Nov 19 09:41 traefik.yml
traefikadmin@traefik:~/traefik/data$

The directories acme.json and traefik.yml are auto created - not sure why.

This is the problem...

Why have you a directory with the name traefik.yml?
Use the correct file:
In stead of:

  • ./data/traefik.yml:/traefik.yml:ro

Use:

  • ./traefik.yml:/traefik.yml:ro

Yep, so it confirms ldez's conjecture. Those directories are created because docker cannot find the eponymous files. Make sure that pathes to them are correct. There are different ways to do that, you can copy the correc files in place of this directories (but then you would not have the correct acme.json, unless you had it from previous installation) or you can mount directories instead of files. The main thing is that what you configure for docker matches the actual files on disk.

@joan.lorenzo - AMAZING! That fixed that.

Now, I get this error:

time="2019-11-21T09:38:23Z" level=error msg="middleware \"traefik-auth@docker\" does not exist" entryPointName=https routerName=traefik-secure@docker

Hi @KingRaymond, this error message means that Traefik cannot find any middleware definition named traefik-auth, within the Docker labels it retrieves.

Where is this middleware defined?

  • If it is on a yml / toml file provided to Traefik, as part of the file provider dynamic configuration, then change the label to - traefik.http.routers.traefik-secure.middlewares=traefik-auth@file
  • If it is expected to be on a docker label, can you share it, has it is not on your current configuration

My config is listed in the OP. Thats all that there is.

Is there something missing?

Thanks for the feedback. Then I confirm that the middleware named traefik-auth is not defined anywhere.

What is the goal of this middleware exactly? Where did you get this configuration ?

The configuration was from here:

But i have figured out the issue. The issue all started with generating the htpasswd credentials.

The author used regex: sed -e s/$/$$/g
The Traefik website uses: sed -e s/\$/\$\$/g

I now have a working config :slight_smile:

Thanks to all for the help! I enjoyed learning all this cool stuff.

2 Likes