如何在可以接受多个端口上的连接的同一后端运行两个docker容器?(How do I run two docker containers in the same backend that can ac

编程入门 行业动态 更新时间:2024-10-24 12:25:21
如何在可以接受多个端口上的连接的同一后端运行两个docker容器?(How do I run two docker containers in the same backend that can accept connections on multiple ports?)

我需要在Traefik后面运行两个相同的容器,这些容器必须接受来自多个端口的请求。 为此,我使用码头服务标签 。 我遇到的问题是当我使用Docker服务标签并尝试扩展到两个容器时,我收到有关已经定义的后端的错误消息。

使用普通标签( traefik.frontend , traefik.port等)工作正常,但添加额外的标签( traefik.whoami.frontend , traefik.whoami.port等)似乎打破了局面。

Docker撰写文件:

version: '2' services: whoami: image: emilevauge/whoami networks: - web labels: - "traefik.http.frontend.rule=Host:whoami.docker.localhost" - "traefik.http.port=80" - "traefik.http.frontend.entryPoints=http" - "traefik.http.frontend.backend=whoami" - "traefik.soap.frontend.rule=Host:whoami.docker.localhost" - "traefik.soap.port=8443" - "traefik.soap.frontend.entryPoints=soap" - "traefik.soap.frontend.backend=whoami" networks: web: external: name: traefik_webgateway

放大:

$ docker-compose scale whoami=2 Creating and starting whoami_whoami_2 ... done

Traefik错误日志:

proxy_1 | time="2017-10-23T15:37:16Z" level=error msg="Near line 39 (last key parsed 'backends.backend-whoami.servers'): Key 'backends.backend-whoami.servers.service' has already been defined."

任何人都可以告诉我这里我做错了什么,或者是否有另一种方法将两个端口映射到容器?

谢谢!

I need to run two identical containers behind Traefik which have to accept requests coming in on multiple ports. To do this I am using docker service labels. The problem that I am running into is when I use Docker service labels and try to scale up to two containers I get an error message about the backend already being defined.

Using the normal labels (traefik.frontend, traefik.port etc.) works fine, but adding the extra labels (traefik.whoami.frontend, traefik.whoami.port etc.) seems to break things.

Docker compose file:

version: '2' services: whoami: image: emilevauge/whoami networks: - web labels: - "traefik.http.frontend.rule=Host:whoami.docker.localhost" - "traefik.http.port=80" - "traefik.http.frontend.entryPoints=http" - "traefik.http.frontend.backend=whoami" - "traefik.soap.frontend.rule=Host:whoami.docker.localhost" - "traefik.soap.port=8443" - "traefik.soap.frontend.entryPoints=soap" - "traefik.soap.frontend.backend=whoami" networks: web: external: name: traefik_webgateway

Scale up:

$ docker-compose scale whoami=2 Creating and starting whoami_whoami_2 ... done

Traefik error log:

proxy_1 | time="2017-10-23T15:37:16Z" level=error msg="Near line 39 (last key parsed 'backends.backend-whoami.servers'): Key 'backends.backend-whoami.servers.service' has already been defined."

Can anyone tell me what I'm doing wrong here or if there is another way to map two ports to a container?

Thanks!

最满意答案

Docker副本管理存在一个错误。

修复程序将在下一个版本中合并: https : //github.com/containous/traefik/pull/2314 。

There was a bug with Docker replicas management.

A fix will be merged in the next release : https://github.com/containous/traefik/pull/2314.

更多推荐

本文发布于:2023-08-04 07:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1413067.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   端口   容器   后端   两个

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!