无法从Docker容器访问WSO2流处理器工作室服务



我使用以下dockerfile实现了WSO2流处理器编辑器配置文件的样本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

构建上述Docker映像时,您将提供Oracle JDK和WSO2流处理器分布(Docker build build上下文中的files目录必须包含这些分布)。

我已经使用

运行了创建的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

是什么原因导致这种无法访问运行服务?任何建议和想法都将受到高度赞赏。

@andy shinn描述了HTTP的收听地址,需要设置为0.0.0.0而不是localhost(127.0.0.0.1)。

您可以在sp_home/conf/conf/editor/deployment.yaml上指定此配置。

我猜测正在发生的事情(基于启动输出)是容器仅在该端口的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 the the default ports with offset涉及端口。您可能可以修改包含编辑器服务器配置的XML文件以在0.0.0.0上收听。

另外,看起来HTTPS在0.0.0.0上侦听9743。您可以在https://localhost:9743(可能带有自签名的SSL证书)。)

最新更新