我正在使用weblogic映像创建一个带有docker的多主机环境。我从oracle经历了article并创建了三台docker机器 machine1,machine2和machine3 。所有机器都是群网络的一部分,其中m1是管理器,其他两个是工作节点。然后,我创建了一个覆盖网络my-net。
docker network create --driver overlay --subnet=10.0.9.0/24 --attachable my-net
machine1 将 Admin 容器附加到群组网络。
docker run -d --name admin --env-file /DockerBaseImage/configurations/domain.properties -v /DockerBaseImage/configurations/:/configurations -v /DockerBaseImage/applications/:/applications -p 9005:8001 --net my-net 12212-baseimage
machine2和machine3分别有ManagedServer2和ManagedServer3。
docker run -d --name ManagedServer1--env-file /DockerBaseImage/configurations/domain.properties -v /DockerBaseImage/configurations/:/configurations -v /DockerBaseImage/applications/:/applications --link admin:wlsadmin --env NM_NAME=Machine2 --env MS_NAME=ManagedServer2 -p 9002:7002 --net my-net 12212-baseimage createServer.sh
docker run -d --name ManagedServer2--env-file /DockerBaseImage/configurations/domain.properties -v /DockerBaseImage/configurations/:/configurations -v /DockerBaseImage/applications/:/applications --link admin:wlsadmin --env NM_NAME=Machine3 --env MS_NAME=ManagedServer3 -p 9002:7002 --net my-net 12212-baseimage createServer.sh
现在当我登录weblogic控制台时,我可以看到所有三台服务器都在运行,但是当我从machine1 telnet machine2 9002 时,我收到连接被拒绝消息。我能做错什么?
Dockerfile :
FROM oracle/weblogic:12.2.1.2-generic
ARG ADMIN_PASSWORD
ARG ADMIN_NAME
ARG DOMAIN_NAME
ARG ADMIN_PORT
ARG CLUSTER_NAME
ARG DEBUG_FLAG
ARG PRODUCTION_MODE
# WLS Configuration (editable during runtime)
# ---------------------------
ENV ADMIN_HOST="wlsadmin" \
NM_PORT="5556" \
MS_PORT="7002" \
DEBUG_PORT="8453" \
CONFIG_JVM_ARGS="-Dweblogic.security.SSL.ignoreHostnameVerification=true"
# WLS Configuration (persisted. do not change during runtime)
# -----------------------------------------------------------
ENV DOMAIN_NAME="${DOMAIN_NAME:-basedomain}" \
DOMAIN_HOME=/domains/${DOMAIN_NAME:-basedomain} \
ADMIN_NAME="${ADMIN_NAME:-AdminServer}" \
ADMIN_PORT="${ADMIN_PORT:-8001}" \
CLUSTER_NAME="${CLUSTER_NAME:-DockerCluster}" \
debugFlag="${DEBUG_FLAG:-false}" \
PRODUCTION_MODE="${PRODUCTION_MODE:-prod}" \
PATH=$PATH:/u01/oracle/oracle_common/common/bin:/u01/oracle/wlserver/common/bin:/domains/${DOMAIN_NAME:-basedomain}/bin:/u01/oracle
# Add files required to build this image
ADD resources/* /u01/oracle/
ADD *.jar /u01/oracle/wlserver/common/templates/wls/
ADD configurations/ /configurations
ADD applications/ /applications
USER root
RUN mkdir /domains/ && \
chown -R oracle /domains/
USER oracle
RUN /u01/oracle/wlst /u01/oracle/create-wls-domain.py && \
mkdir -p $DOMAIN_HOME/servers/AdminServer/security && \
echo "username=weblogic" > $DOMAIN_HOME/servers/AdminServer/security/boot.properties && \
echo "password=${ADMIN_PASSWORD:-weblogic1}" >> $DOMAIN_HOME/servers/AdminServer/security/boot.properties && \
echo ". $DOMAIN_HOME/bin/setDomainEnv.sh" >> /u01/oracle/.bashrc
# Expose Node Manager default port, and also default for admin and managed server
EXPOSE $NM_PORT $ADMIN_PORT $MS_PORT $DEBUG_PORT
WORKDIR $DOMAIN_HOME
# Define default command to start bash.
CMD ["startWLDomain.sh"]
Docker版本:
Client:
Version: 1.13.1
API version: 1.26
Go version: go1.7.5
Git commit: 092cba3
Built: Wed Feb 8 06:44:54 2017
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Go version: go1.7.5
Git commit: 092cba3
Built: Wed Feb 8 06:44:54 2017
OS/Arch: linux/amd64
Experimental: false
netstat on machine2:
tcp6 0 0 :::9002 :::* LISTEN
托管服务器容器上的netstat:
tcp6 0 0 10.0.9.3:7002 :::* LISTEN
答案 0 :(得分:0)
您正在使用-p 9002:7002
定义端口映射。这意味着您可以从泊坞主机执行telnet localhost 9002
以到达相应的容器。容器公开的端口是7002
,因此,如果要从其中一个容器执行命令,则需要执行telnet machine2 7002
。
根据您的输入,您可能想尝试:
docker service create \
--name=service1 \
--publish mode=host,target=7002,published=9002,protocol=tcp \
...
这将创建一个服务(一个实例),并在部署任务的节点上发布端口(mode=host
)。