Failed to open the plugin manifest /.traefik.yml. traefik can't find or read the manifest

I'm new to Traefik. I'm trying to develop a plugin and "connect" it to my webserver using Docker Compose. I use docker compose for development. When I try to run the Docker Compose I encountered this error:

/dev/echo-docker-compose $ docker-compose up --build
Starting echo-server ... done
Recreating traefik   ... done
Attaching to echo-server, traefik
echo-server    | Echo server listening on port 8080.
traefik        | time="2022-03-18T07:40:11Z" level=info msg="Configuration loaded from flags."
traefik        | time="2022-03-18T07:40:11Z" level=info msg="Traefik version 2.6.1 built on 2022-02-14T16:50:25Z"
traefik        | time="2022-03-18T07:40:11Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"traefik\":{\"address\":\":8080\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":\"10s\"},\"respondingTimeouts\":{\"idleTimeout\":\"3m0s\"}},\"forwardedHeaders\":{},\"http\":{},\"udp\":{\"timeout\":\"3s\"}},\"web\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":\"10s\"},\"respondingTimeouts\":{\"idleTimeout\":\"3m0s\"}},\"forwardedHeaders\":{},\"http\":{},\"udp\":{\"timeout\":\"3s\"}}},\"providers\":{\"providersThrottleDuration\":\"2s\",\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":\"15s\"}},\"api\":{\"insecure\":true,\"dashboard\":true},\"log\":{\"level\":\"DEBUG\",\"format\":\"common\"},\"pilot\":{\"dashboard\":true},\"experimental\":{\"localPlugins\":{\"traefik-plugin-example\":{\"moduleName\":\"github.com/usergithub/traefik-plugin-example\"}}}}"
traefik        | time="2022-03-18T07:40:11Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://doc.traefik.io/traefik/contributing/data-collection/\n"
traefik        | 2022/03/18 07:40:11 traefik.go:79: command traefik error: 1 error occurred:
traefik        |        * failed to open the plugin manifest plugins-local/src/github.com/usergithub/traefik-plugin-example/.traefik.yml: open plugins-local/src/github.com/usergithub/traefik-plugin-example/.traefik.yml: no such file or directory
traefik        | 
traefik        | 
traefik exited with code 1

I think I can conclude that the cause of this error is that it can't find the .traefik.yml file which is quite obvious. But, I already have the file in that directory.

This is my full directory structure

dev/plugins-local/
    └── src
        └── github.com
            └── traefik
                └── traefik-plugin-example
                    ├── plugin.go
                    ├── plugin_test.go
                    ├── .traefik.yml
                    ├── go.mod
                    ├── Dockerfile
                    ├── Makefile
    ├── traefik
    ├── traefik-plugin.go
    ├── rules-plugin.go
dev/echo-docker-compose/
    └── docker-compose.yml
    └── cmd
        └── ....

For some reasons, I think Docker Compose can't read .traefik.yml. But, it's also the same case when I try to run ./traefik --configfile traefik-plugin.yml from dev/plugins-local. It also throws the same error where it can't read the .traefik.yml.

Anyone knows how to fix this problem?

This is the relevant codes:

On server repo

# dev/echo-docker-compose/.env
PLUGIN_MODULE=github.com/usergithub/traefik-plugin-example
PLUGIN_NAME=traefik-plugin-example

# dev/echo-docker-compose/docker-compose.yml
version: "3.3"

services:
  traefik:
    image: "traefik:v2.6"
    container_name: "traefik"
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--experimental.localPlugins.${PLUGIN_NAME}.moduleName=${PLUGIN_MODULE}"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

  echo-server:
    image: "usergithub/echo-server"
    container_name: "echo-server"
    labels:
      - "traefik.enable=true"
      # The domain the service will respond to
      - "traefik.http.routers.echoserver.rule=Host(`echoserver.localhost`)"
      # Allow request only from the predefined entry point named "web"
      - "traefik.http.routers.echoserver.entrypoints=web"
      - "traefik.http.routers.echoserver.entrypoints=web"
      - "traefik.http.routers.echoserver.middlewares=echoserver-demo"
      - "traefik.http.middlewares.echoserver-demo.plugin.${PLUGIN_NAME}.headers.DoesPluginWork=YES"
      - "traefik.http.routers.echoserver.tls.certresolver=default"

On plugin repo

# dev/plugins-local/traefik-plugin.go
pilot:
    token: "token"

api:
  dashboard: true
  insecure: true

experimental:
  localPlugins:
    traefik-plugin-example:
      moduleName: github.com/usergithub/traefik-plugin-example

entryPoints:
  http:
    address: ":8000"
    forwardedHeaders:
      insecure: true
  
providers:
  file:
    filename: rules-plugin.yaml 
# dev/plugins-local/src/github.com/usergithub/traefik-plugin-example/.traefik.yml
displayName: Traefik Example Plugin
type: middleware

import: github.com/usergithub/traefik-plugin-example

summary: 'Write plugin'

testData:
  userAgent:
    - Firefox
    - Mozilla/5.0

Hello @panah,

It might be due to a missing volume on docker compose to add the local plugin inside your docker container.

Hope it helps

Thanks. Tried adding it to the volumes, but now it gives a different error.

failed to decode the plugin manifest plugins-local/src/github.com/usergithub/traefik-plugin-example/.traefik.yml: yaml: input error: read plugins-local/src/github.com/usergithub/traefik-plugin-example/.traefik.yml: is a directory

It cant decode the manifest because it thinks it's a directory. Any solution?

I think you get mixed up in volumes, your volume should be:

services:
  traefik:
    ...
    volumes:
      ...
      - "./dev/plugins-local/:/plugins-local/"

You need to have the plugin source code in your docker container.

This is due to mapping a directory as a file in a volume.

1 Like

Thanks! I'm gonna try playing around with it. I've gotta admit I'm not really great with docker. I thought it was Traefik's issue.

1 Like

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