无法从Docker容器访问WSO2 Stream Processor Studio服务

我使用以下Dockerfile为WSO2 Stream Processor 编辑器configuration文件实施了一个示例Docker镜像:

FROM ubuntu:16.04 MAINTAINER WSO2 Docker Maintainers "dev@wso2.org" # set user configurations ARG USER=wso2carbon ARG USER_GROUP=wso2 ARG USER_HOME=/home/${USER} # set dependant files directory ARG FILES=./files # set jdk configurations ARG JDK_ARCHIVE=jdk-8u*-linux-x64.tar.gz ARG JAVA_HOME=${USER_HOME}/java # set wso2 product configurations ARG WSO2_SERVER=wso2sp ARG WSO2_SERVER_VERSION=4.0.0 ARG WSO2_SERVER_PACK=${WSO2_SERVER}-${WSO2_SERVER_VERSION}*.zip ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER}-${WSO2_SERVER_VERSION} # install required packages RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests \ curl \ iproute2 \ telnet \ unzip && \ rm -rf /var/lib/apt/lists/* # create a user group and a user RUN groupadd --system ${USER_GROUP} && \ useradd --system --create-home --home-dir ${USER_HOME} --no-log-init -g ${USER_GROUP} ${USER} # copy the jdk and wso2 product distribution zip files to user's home directory COPY ${FILES}/${JDK_ARCHIVE} ${FILES}/${WSO2_SERVER_PACK} ${USER_HOME}/ # install the jdk, wso2 server, remove distributions and set folder permissions RUN mkdir -p ${JAVA_HOME} && \ tar -xf ${USER_HOME}/${JDK_ARCHIVE} -C ${JAVA_HOME} --strip-components=1 && \ unzip -q ${USER_HOME}/${WSO2_SERVER_PACK} -d ${USER_HOME}/ && \ rm ${USER_HOME}/${JDK_ARCHIVE} && \ rm ${USER_HOME}/${WSO2_SERVER_PACK} && \ chown -R ${USER}:${USER_GROUP} ${USER_HOME} && \ chmod -R g=u ${USER_HOME} # set the user and work directory USER ${USER} WORKDIR ${USER_HOME} # set environment variables ENV JAVA_HOME=${JAVA_HOME} \ PATH=$JAVA_HOME/bin:$PATH \ WSO2_SERVER_HOME=${WSO2_SERVER_HOME} # expose ports EXPOSE 9390 9715 9615 7714 7614 ENTRYPOINT ${WSO2_SERVER_HOME}/bin/editor.sh 

在构build上面的Docker镜像时,您需要提供Oracle JDK和WSO2 Stream Processor发行版(Docker构build上下文中的files目录必须包含这些发行版)。

我已经运行了创build的Docker镜像

 docker run -it -p 9390:9390 wso2sp:4.0.0 

没有港口

 docker run -it wso2sp:4.0.0 

转发,但我无法从端口9390访问编辑器UI。如下面的日志所示,我们应该能够通过URL访问服务

 http://localhost:9390/editor (when port forwarding) 

或者通过

 http://<private_container_IP>:9390/editor (no port forwarding) 

我也发现服务器已经通过日志成功启动了,如下所示:

 JAVA_HOME environment variable is set to /home/wso2carbon/java CARBON_HOME environment variable is set to /home/wso2carbon/wso2sp-4.0.0 RUNTIME_HOME environment variable is set to /home/wso2carbon/wso2sp-4.0.0/wso2/editor [2017-12-25 22:47:44,035] INFO {org.wso2.carbon.launcher.extensions.OSGiLibBundleDeployerUtils updateOSGiLib} - Successfully updated the OSGi bundle information of Carbon Runtime: editor osgi> [2017-12-25 22:47:46,187] INFO {org.wso2.msf4j.internal.websocket.WebSocketServerSC} - All required capabilities are available of WebSocket service component is available. [2017-12-25 22:47:46,190] INFO {org.wso2.carbon.metrics.core.config.model.JmxReporterConfig} - Creating JMX reporter for Metrics with domain 'org.wso2.carbon.metrics' [2017-12-25 22:47:46,211] INFO {org.wso2.carbon.metrics.core.reporter.impl.AbstractReporter} - Started JMX reporter for Metrics [2017-12-25 22:47:46,269] INFO {org.wso2.msf4j.analytics.metrics.MetricsComponent} - Metrics Component is activated [2017-12-25 22:47:46,274] INFO {org.wso2.carbon.databridge.agent.internal.DataAgentDS} - Successfully deployed Agent Server [2017-12-25 22:47:46,307] INFO {org.wso2.msf4j.internal.websocket.EndpointsRegistryImpl} - Endpoint Registered : /console [2017-12-25 22:47:46,457] INFO {org.wso2.carbon.event.simulator.core.service.CSVFileDeployer} - CSV file deployer initiated. [2017-12-25 22:47:46,460] INFO {org.wso2.carbon.event.simulator.core.service.SimulationConfigDeployer} - Simulation config deployer initiated. [2017-12-25 22:47:46,463] INFO {org.wso2.carbon.siddhi.editor.core.internal.WorkspaceDeployer} - Workspace artifact deployer initiated. [2017-12-25 22:47:46,518] INFO {org.wso2.carbon.cluster.coordinator.rdbms.internal.RDBMSCoordinationServiceComponent} - Cluster coordination has been disabled. Enable it in deployment.yaml to use the clustering service [2017-12-25 22:47:46,645] INFO {org.wso2.carbon.stream.processor.statistics.api.StatisticsApi} - org.wso2.carbon.stream.processor.statistics.api.StatisticsApi service component has started. [2017-12-25 22:47:46,759] INFO {org.wso2.carbon.siddhi.editor.core.internal.StartupComponent} - Editor Started on : http://localhost:9390/editor [2017-12-25 22:47:46,762] INFO {org.wso2.msf4j.internal.MicroservicesServerSC} - All microservices are available [2017-12-25 22:47:46,825] INFO {org.wso2.transport.http.netty.listener.ServerConnectorBootstrap$HTTPServerConnector} - HTTP(S) Interface starting on host 127.0.0.1 and port 9390 [2017-12-25 22:47:46,828] INFO {org.wso2.transport.http.netty.listener.ServerConnectorBootstrap$HTTPServerConnector} - HTTP(S) Interface starting on host 0.0.0.0 and port 9743 [2017-12-25 22:47:46,888] INFO {org.wso2.carbon.databridge.receiver.binary.internal.BinaryDataReceiver} - Started Binary SSL Transport on port : 9715 [2017-12-25 22:47:46,889] INFO {org.wso2.carbon.databridge.receiver.binary.internal.BinaryDataReceiver} - Started Binary TCP Transport on port : 9615 [2017-12-25 22:47:46,897] INFO {org.wso2.carbon.databridge.receiver.thrift.ThriftDataReceiver} - Thrift Server started at 0.0.0.0 [2017-12-25 22:47:46,911] INFO {org.wso2.carbon.databridge.receiver.thrift.ThriftDataReceiver} - Thrift SSL port : 7714 [2017-12-25 22:47:46,913] INFO {org.wso2.carbon.databridge.receiver.thrift.ThriftDataReceiver} - Thrift port : 7614 [2017-12-25 22:47:46,917] INFO {org.wso2.carbon.databridge.core.internal.DataBridgeDS} - Successfully deployed Agent Server [2017-12-25 22:47:46,930] INFO {org.wso2.carbon.kernel.internal.CarbonStartupHandler} - WSO2 Stream Processor started in 3.181 sec 

什么原因导致无法访问正在运行的服务? 任何build议和意见,高度赞赏。

我正在猜测发生了什么(基于启动输出)是容器只能在该端口上的localhost上侦听。 监听地址需要设置为0.0.0.0而不是localhost (请注意,端口9390的接口在127.0.0.1上监听,但97430.0.0.0 )。

这是因为你连接到Docker容器是通过执行NAT的主机上的一个DOcker桥。 容器中的locahost与您的实际主机上的localhost

https://docs.wso2.com/display/APPM120/Changing+the+Default+Ports+with+Offset有关于端口的信息&#x3002; 您可能可以修改包含编辑器服务器configuration的XML文件以在0.0.0.0上进行侦听。

另外,看起来HTTPS正在监听端口9743 0.0.0.0 。 您可以通过https:// localhost:9743 (可能使用自签名的SSL证书)使用它。)