我是特雷菲克的新手。我正在尝试开发一个插件,并使用Docker将它“连接”到我的and服务器上。我使用码头构图进行开发。当我试图运行Docker撰写时,我遇到了以下错误:
/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我想我可以得出结论,这个错误的原因是它找不到.traefik.yml文件,这是很明显的。但是,我已经在那个目录里有文件了。
这是我的完整目录结构
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
└── ....出于某些原因,我认为Docker撰写不懂.traefik.yml。但是,当我尝试从./traefik --configfile traefik-plugin.yml运行dev/plugins-local时,情况也是一样的。它还在无法读取.traefik.yml的地方抛出相同的错误。
有人知道怎么解决这个问题吗?
以下是有关守则:
服务器回购
# 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"插件回购
# 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.0https://stackoverflow.com/questions/71523956
复制相似问题