使用Docker在Jelastic中进行端口转发 [英] Port forwarding in Jelastic with Docker

查看:87
本文介绍了使用Docker在Jelastic中进行端口转发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的应用程序,该应用程序在端口4567上具有rest api,并在我的docker容器中的Jelastic cloud中运行它.现在,我想将端口4567转发到外部世界.当我在本地运行docker时,我可以这样做: docker run -d -p 4567:4567 -ti myapp/bin/bash
但是,如果没有外部IP,我该怎么做才能做到呢?我也尝试过使用jelastic端点,但是端口不可用.还可以在jelastic的文档中找到一些信息:"如果您的Docker容器没有连接外部IP,Jelastic会执行自动端口重定向.这意味着,如果应用程序侦听TCP级别的自定义端口,Jelastic将尝试自动检测到该端口并将所有传入请求转发到该端口号.因此,在大多数情况下,您创建的dockerized应用或服务将在创建后立即通过Internet在相应节点的域下提供."
要构建Docker映像,我使用Dockerfile,它具有"EXPOSE 4567"字段.

解决方案

@Catalina,

请注意,由于Jelastic使用PCS,因此无需在Jelastic中公开端口.

让我们解释一下哪个端口正在监听共享负载平衡器(SLB)和可以转发到容器:

80 -> HTTP

8080 -> HTTP

8686 -> HTTP

8443 -> SSL

4848 (glassfish管理员)-> SSL

4949 (wildfly admin)-> HTTP

7979 (导入/导出功能)-> SSL

如果要指定其他端口而不是通过自动重定向功能选择,则可以通过指定 JELASTIC_EXPOSE 来实现./docker-variables"rel =" nofollow noreferrer> docker变量在环境设置向导以指定所需的端口.

JELASTIC_EXPOSE 变量,应使用以下值:

  • 0 或DISABLED或FALSE-禁用自动重定向
  • 1-65535 范围内的数字-定义用于设置相应重定向的必需端口

此外,您也可以通过端点映射所需的专用端口(以通过共享LB ),并将您的服务绑定到接收的地址和共享端口.

I have simple application which has rest api on port 4567 and run it in my docker container in jelastic cloud. Now I want to forward port 4567 to the external world. When I run docker locally I can do it like that: docker run -d -p 4567:4567 -ti myapp /bin/bash
But how can I do that in jelastic without external IP? I've also tried to use jelastic endpoints but port is not available. Also found some information on jelastic's docs: "In case your Docker container does not have an external IP attached, Jelastic performs an automatic port redirect. This means that if application listens to a custom port on TCP level, Jelastic will try to automatically detect it and forward all the incoming requests to this port number. As a result, in most cases, your dockerized app or service will become available over the Internet under the corresponding node’s domain right after creation."
To build docker image I use Dockerfile and it has "EXPOSE 4567" field.

解决方案

@Catalina,

Pay attention that there is no need to expose ports in Jelastic because it uses PCS container-based virtualization, which is more technologically advanced compared to the native Docker containers’ implementation: it has the built-in support of the natural virtual host-routed network adapters.

By default, Jelastic automatically detects the ports, that are predefined to be listened by an application within the appropriate Docker image settings, and applies the required redirects to ensure container’s accessibility right after the deployment.

Let us explain which ports are listening on Shared Load Balancer (SLB) and can be forwarded to the containers:

80 -> HTTP

8080 -> HTTP

8686 -> HTTP

8443 -> SSL

4848 (glassfish admin) -> SSL

4949 (wildfly admin) -> HTTP

7979 (import/export feature) -> SSL

In the case when you want to specify another port instead of selected by auto-redirect functionality you can do it by specifying the JELASTIC_EXPOSE docker variable in the environment settings wizard to specify the needed port.

JELASTIC_EXPOSE variable should be used, with the following values as possible:

  • 0 or DISABLED or FALSE - to disable auto-redirect
  • a number within the 1-65535 range - to define the required port for setting the corresponding redirect

Also, you can either map the required private port via endpoint (for being accessible over Shared LB) and bind your service to the received address and shared port.

这篇关于使用Docker在Jelastic中进行端口转发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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