我使用以下Dockerfile为WSO2 Stream Processor editor profile实现了一个示例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 Stream Processor发行版(Docker构建上下文中的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
是什么原因导致无法访问正在运行的服务?任何建议和想法都受到高度赞赏。
答案 0 :(得分:2)
正如@Andy Shinn所描述的,http的监听地址需要设置为0.0.0.0而不是localhost(127.0.0.1)。
您可以在listenerConfigurations下的SP_HOME / conf / editor / deployment.yaml上指定此配置。
答案 1 :(得分:1)
我猜测正在发生的事情(基于启动输出)是容器只在该端口上监听localhost
。监听地址需要设置为0.0.0.0
而不是localhost
(注意端口9390
的接口正在监听127.0.0.1
但9743
正在0.0.0.0
上1}})。
这是因为您与Docker容器的连接是通过执行NAT的主机上的DOcker桥接器实现的。容器中的locahost
与您实际主机上的localhost
不同。
https://docs.wso2.com/display/APPM120/Changing+the+Default+Ports+with+Offset部分有关端口的信息。您可以修改包含编辑器服务器配置的XML文件,以便在0.0.0.0
上进行侦听。
或者,看起来HTTPS正在0.0.0.0
上侦听端口9743
。您可以在https://localhost:9743使用它(可能使用自签名SSL证书)。)