多个Docker容器可以使用同一主机/端口运行吗? [英] Can multiple Docker containers run using the same host/port?

查看:2441
本文介绍了多个Docker容器可以使用同一主机/端口运行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

热衷于将Docker用于REST服务项目.我有一个问题是我们是否可以使用Docker在同一主机/端口上运行该服务的多个版本.

Been looking into using Docker for a REST service project. One question I have is whether we could use Docker to run multiple versions of the service on the same host/port.

例如,我想在{myserver}:8080/v1/拥有一个端点,在{myserver}:8080/v2/拥有另一个端点.

For example, I want to have an endpoint at {myserver}:8080/v1/ and another at {myserver}:8080/v2/.

如果完全相关,那么它们将是在Spring Boot REST框架上使用Java jar构建的基于Java:8的Docker映像.

If it's relevant at all, these would be Java:8 based Docker images constructed with a java jar on the Spring Boot REST framework.

使用Docker容器有可能吗?

Is this possible with Docker containers?

推荐答案

您可以使用不同的主机端口运行两个容器,并使用haproxy/nginx/varnish(本机或在另一个容器内部)侦听主机端口并进行重定向根据URL定位到正确的容器.

You can run both containers using different host ports, and use a haproxy/nginx/varnish (native or inside another container) listening to the host port, and redirecting to the right container based on the URL.

这篇关于多个Docker容器可以使用同一主机/端口运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆