我正在设置一个Docker集群,并尝试在docker Manager上获得正常工作的traefik反向和portainer + agent。但是该容器不是公开可用的。
我是Docker和反向代理的新手,所以我没有尝试超过显示的代码。
开始于: docker stack deploy -c stack.yml stack0
stack.yml
version: "3.3"
services:
traefik:
image: traefik
command: --docker.swarmmode
networks:
- traefik-net
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefikdata:/etc/traefik
deploy:
placement:
constraints: [node.role==manager]
portainer-agent:
image: portainer/agent
environment:
AGENT_CLISTER_ADDR: tasks.agent
AGENT_PORT: 9001
LOG_LEVEL: debug
ports:
- target: 9001
published: 9001
protocol: tcp
mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- portainer-agent_network
- traefik-net
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
portainer:
image: portainer/portainer
command: -H tcp://tasks.agent:9001 --tlsskipverify
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "./portainerdata:/data"
networks:
- portainer-agent_network
- traefik-net
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.role == manager]
labels:
- "traefik.enable=true"
- "traefik.port=9000"
- "traefik.docker.network=stack0_traefik-net"
- "traefik.frontend.rule=Host:portainer.intern.domain.tld"
networks:
traefik-net:
portainer-agent_network:
driver: overlay
attachable: true
traefikdata / traefik.toml
logLevel = "INFO"
defaultEntryPoints = ["http", "https"]
[web]
address = ":8080"
[docker]
domain = "traefik.intern.domain.tld"
watch = true
exposedbydefault = false
# Force HTTPS
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
# Let's encrypt configuration
[acme]
email="network@techgods.biz"
storage="/etc/traefik/acme/acme.json"
entryPoint="https"
acmeLogging=true
OnHostRule=true
[acme.httpChallenge]
entryPoint = "http"
我希望运行Traefik反向代理,可以通过traefik.intern.domain.tld访问UI,可以通过portainer.intern.domain.tld访问portainer
答案 0 :(得分:1)
为完全清楚起见,我还将放置entryPoints
定义:
- "traefik.frontend.entryPoints=https"
您确定这部分是正确的吗?
- "traefik.docker.network=stack0_traefik-net"
它似乎与您的网络定义不符:
networks:
traefik-net:
portainer-agent_network:
driver: overlay
attachable: true
我强烈建议您在不使用网络定义的情况下使其正常运行,然后再一次添加这些定义。
答案 1 :(得分:0)
在尝试恢复我的stack.yml几个小时后,我从头开始,阅读了更多文档,并发现了很多有用的stackoverflow帖子。
最后,我实际上有这个:
version: "3"
services:
traefik:
image: traefik:latest
command: --web --docker --docker.swarmmode --docker.watch --docker.domain=intern.domain.tld --logLevel=DEBUG
deploy:
placement:
constraints: [node.role==manager]
restart_policy:
condition: on-failure
labels:
- "traefik.port=8080"
- "traefik.docker.network=proxy"
- "traefik.frontend.rule=Host:traefik.intern.domain.tld"
ports:
- "80:80"
- "5003:8080"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /dev/null:/traefik.toml
networks:
- proxy
portainer:
image: portainer/portainer:latest
command: --no-auth -H unix:///var/run/docker.sock
deploy:
placement:
constraints: [node.role == manager]
labels:
- "traefik.portainer.port=9000"
- "traefik.docker.network=proxy"
- "traefik.frontend.rule=Host:portainer.intern.domain.tld"
ports:
- "5001:9000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- proxy
networks:
proxy:
现在,我需要让Portainer代理工作。我会努力的。在第一个视图上,portainer和traefik在正确的端口上可以到达。 SSL还没有,但是为此我在下面提出了疑问。
portainer.intern.domain.tld:5001
和traefik.intern.domain.tld:5001
仍然都是portainer
,但是traefik.intern.domain.tld:5001
应该无法访问-仅:5003
与traefik
-另外一个一路走来。先谢谢你。