简体   繁体   English

Traefik可以在固定端口上创建到Docker主机上容器的路由吗?

[英]Can Traefik create routes with fixed ports to containers on a Docker host?

Let's say there are two MariaDB containers running on the same host of a Docker swarm. 假设有两个MariaDB容器在Docker群的同一主机上运行。 Each container has its internal port 3306 which is dynamically exposed to eg 30004 and 30056. 每个容器具有其内部端口3306,其内部动态地暴露于例如30004和30056。

I'd like an external container (not defined in the stack) to access the database of one stack by a hostname and fixed port, eg mariadb_s1:3306 (redirected to MariaDB of stack 1 on port 30004) as shown in the following picture. 我希望一个外部容器(未在堆栈中定义)通过主机名和固定端口访问一个堆栈的数据库,例如mariadb_s1:3306 (在端口30004上重定向到堆栈1的MariaDB),如下图所示。

We also have a Traefik instance running on the Docker host. 我们也有一个运行在Docker主机上的Traefik实例。 Is Traefik capable to create these routes? Traefik有能力创建这些路线吗?

原理图概述

I don't think traefik supports TCP proxying at the moment but it seems to be planned https://github.com/containous/traefik/issues/10 我不认为traefik目前不支持TCP代理,但似乎已计划在https://github.com/containous/traefik/issues/10

But even with TCP proxy support it might be hard to route based on hostname as I don't think the MySQL protocol includes the hostname (might be wrong). 但是即使有TCP代理支持,也可能难以基于主机名进行路由,因为我不认为MySQL协议包括主机名(可能是错误的)。 If so one solution could be to use TLS and route based on SNI. 如果是这样,一种解决方案可能是使用TLS并基于SNI进行路由。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Traefik 不同的端口用于不同的 Docker 容器 - Traefik different ports for different Docker containers 同一主机中的docker容器是否具有相同的端口 - Can docker containers within same host have same ports 一台主机上带有Traefik的两个Docker容器 - Two docker containers with Traefik on one host Docker:将主机端口映射到多个Docker容器 - Docker: Map host ports to several docker containers 同一主机上的 Docker 容器侦听相同的 2 个端口 - Docker containers on same host listening to the same 2 ports 如何通过在不同主机端口上运行相同的 docker-compose 文件来创建相同映像的多个容器? - How to create multiple containers of same image by running same docker-compose file on different host ports? Docker群拒绝创建具有已发布端口的容器 - Docker swarm refuses to create containers with published ports 使用 Traefik 和 Docker 组合在同一主机上提供 2 个服务,但路由不同 - Use Traefik with Docker Compose to serve 2 services on the same host but different routes Docker容器在Mac上将端口暴露给主机时出现问题 - Docker containers having trouble exposing ports to host on Mac Docker将两个容器上的相同端口映射到主机上的不同端口 - Docker Mapping Same Port On Two Containers To Different Ports On Host
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM