Unable to go past the "traefik.yml: is a directory" error

Hi,
I'm a newbie at this and unable to fix the traefik error, not being able to read the traefik.yml, because it assumes it's a directory. I've reviewed the solutions in the forum, Reddit and still cant seem to resolve the issue. Would someone help.

See below error, my docker-compose.yml file and the traefik.yml files.

2023/07/23 22:45:10 command traefik error: read /traefik.yml: is a directory
image

---
version: "3"
services:
  traefik:
    image: traefik:latest
    container_name: traefik
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    ports:
      - 80:80
      - 443:443
    environment:
      - CF_API_EMAIL=email@example.com
      - CF_DNS_API_TOKEN=ABCDEF-abdfddsfsdberftgretewf-123456789
      # - CF_API_KEY=ABCDEF_GHIJK_12456
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /home/user/apps/treafik/traefik.yml:/traefik.yml:ro
      - /home/user/apps/treafik/acme.json:/acme.json
      - /home/user/apps/treafik/config.yml:/config.yml:ro
      - /home/user/apps/treafik/logs:/var/log/traefik
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.entrypoints=http"
      - "traefik.http.routers.traefik.rule=Host(`traefik.example.com`)"
      - "traefik.http.middlewares.traefik-auth.basicauth.users=USER:PASSWORD"
      - "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
      - "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
      - "traefik.http.routers.traefik-secure.entrypoints=https"
      - "traefik.http.routers.traefik-secure.rule=Host(`traefik.example.com`)"
      - "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
      - "traefik.http.routers.traefik-secure.tls=true"
      - "traefik.http.routers.traefik-secure.tls.certresolver=cloudflare"
      - "traefik.http.routers.traefik-secure.tls.domains[0].main=example.com"
      - "traefik.http.routers.traefik-secure.tls.domains[0].sans=*.example.com"
      - "traefik.http.routers.traefik-secure.service=api@internal"
    restart: unless-stopped

networks:
  proxy:
    external: true
api:
  dashboard: true
  debug: true

entryPoints:
  http:
    address: ":80"
    http:
      redirections:
        entryPoint:
          to: https
          scheme: https
  https:
    address: ":443"

serversTransport:
  insecureSkipVerify: true

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

certificatesResolvers:
  cloudflare:
    acme:
      email: email@example.com
      storage: acme.json
      dnsChallenge:
        provider: cloudflare
        resolvers:
          - "1.1.1.1:53"
          - "1.0.0.1:53"

Hello,

first, you should try to run docker-compose down --remove-orphan to stop and clean your environment.

Also, there is a typo in your configuration it's traefik and not treafik (in the volumes)

You should also check if /home/user/apps/treafik/traefik.yml is a file (with the typo :smile: )

I picked your files and I don't reproduce the problem.

command traefik error: read /traefik.yml: is a directory

It's because you mounted a non existent path (related to the typo)


Your configuration contains some mistakes and not recommended practices.
I would like to suggest you a better starting point:

one file to rule them all

docker-compose.yml:

version: "3"
services:
  traefik:
    image: traefik:v2.10
    container_name: traefik
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    ports:
      - 80:80
      - 443:443
    environment:
      - CF_API_EMAIL=email@example.com
      - CF_DNS_API_TOKEN=ABCDEF-abdfddsfsdberftgretewf-123456789
      # - CF_API_KEY=ABCDEF_GHIJK_12456
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./letsencrypt/:/letsencrypt
    command:
      # dashboard
      - --api.dashboard=true

      # Log
      - --log.level=debug

      # Entrypoints
      - --entryPoints.web.address=:80
      - --entrypoints.web.http.redirections.entrypoint.to=websecure
      - --entrypoints.web.http.redirections.entrypoint.scheme=https
      - --entryPoints.websecure.address=:443
      - --entrypoints.websecure.http.tls=true
      - --entrypoints.websecure.http.tls.certResolver=leresolver

      # ACME configuration
      - --certificatesresolvers.leresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
      - --certificatesresolvers.leresolver.acme.email=email@example.com
      - --certificatesresolvers.leresolver.acme.storage=/letsencrypt/acme.json
      - --certificatesresolvers.leresolver.acme.dnschallenge.provider=cloudflare
      - --certificatesresolvers.leresolver.acme.dnschallenge.resolvers=1.1.1.1:53
      
      # providers
      - --providers.docker.exposedbydefault=false

    labels:
      traefik.enable: 'true'

      traefik.http.routers.dashboard.rule: Host(`traefik.example.com`)
      traefik.http.routers.dashboard.middlewares: traefik-auth
      traefik.http.routers.dashboard.tls.domains[0].main: example.com
      traefik.http.routers.dashboard.tls.domains[0].sans: '*.example.com'
      traefik.http.routers.dashboard.service: api@internal

      traefik.http.middlewares.traefik-auth.basicauth.users: 'USER:PASSWORD'
    restart: unless-stopped

networks:
  proxy:
    external: true
1 Like

The TYPO!!!!! gosh, that fixed it.

Thanks Idez for the better docker-compose file.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.