我在Windows操作系统中具有Ubuntu 18.04虚拟机。在虚拟机中,安装了docker,它是docker主机。使用Oracle Linux7创建映像以安装Weblogic 12,并手动将应用程序登录到容器中。端口已成功映射,并且Weblogic在容器内部运行,但是在Docker主机和Docker主机外部无法访问。 我想知道我是否缺少任何配置,并且想知道如何对Docker网络进行故障排除以解决此问题。
FROM oraclebase:v2 # Have the base image created where I have installed Java
#prerequisite create_basedomain.py, verdomain.properties,fmw_12.2.1.0.0_wls_Disk1_1of1.zip
USER root
ENV JAVA_HOME /opt/jdk/jdk1.8.0_131
ENV WLS_PKG fmw_12.2.1.0.0_wls_Disk1_1of1.zip
ENV WLS_JAR fmw_12.2.1.0.0_wls.jar
ENV CREATE_DOMAIN_SCRIPT create_basedomain.py
#This properties file should be passed as a template file. not env specific.
ENV DOMAIN_PROPERTIES verdomain.properties
# Prerequisites
# any prerequisite packages for Weblogic
# Create Oracle base directories
RUN mkdir -p /u01/app/oracle/product/wls122100 && \
mkdir -p /u01/app/oracle/config/domains && \
mkdir -p /u01/app/oracle/config/applications
COPY $WLS_PKG wls.rsp oraInst.loc /u01/app/oracle/
COPY $CREATE_DOMAIN_SCRIPT /u01/app/oracle
COPY $DOMAIN_PROPERTIES /u01/app/oracle
# Create functional useraccount
RUN chmod a+xr /u01 && useradd -b /u01 -m -s /bin/bash oracle
WORKDIR /u01/app/oracle/
RUN chown oracle:oracle -R /u01
USER oracle
# Adjust paths as required.
ENV CONFIG_JVM_ARGS="-Djava.security.egd=file:/dev/./urandom"
ENV ORACLE_BASE /u01/app/oracle
ENV ORACLE_HOME $ORACLE_BASE/product/wls122100
ENV MW_HOME $ORACLE_HOME
ENV WLS_HOME $MW_HOME/wlserver
ENV WL_HOME $WLS_HOME
ENV DOMAIN_BASE $ORACLE_BASE/config/domains
ENV DOMAIN_HOME $DOMAIN_BASE/mydomain
ENV PATH="${WLS_HOME}/server/bin:${PATH}"
ENV CLASSPATH=${CLASSPATH}:${WLS_HOME}/server/lib/weblogic.jar:.
RUN echo "export ORACLE_BASE=/u01/app/oracle" >> /u01/oracle/.bash_profile
RUN echo "export ORACLE_HOME=$ORACLE_BASE/product/wls122100" >> /u01/oracle/.bash_profile
RUN echo "export MW_HOME=$ORACLE_HOME" >> /u01/oracle/.bash_profile
RUN echo "export WLS_HOME=$MW_HOME/wlserver" >> /u01/oracle/.bash_profile
RUN echo "export WL_HOME=$WLS_HOME" >> /u01/oracle/.bash_profile
RUN echo "export DOMAIN_BASE=$ORACLE_BASE/config/domains" >> /u01/oracle/.bash_profile
RUN echo "export DOMAIN_HOME=$DOMAIN_BASE/mydomain" >> /u01/oracle/.bash_profile
RUN echo "PATH=$PATH:$WL_HOME/server/bin" >> /u01/oracle/.bash_profile
RUN echo "export CLASSPATH=${CLASSPATH}:${WLS_HOME}/server/lib/weblogic.jar:." >> /u01/oracle/.bash_profile
RUN echo ". \$WL_HOME/server/bin/setWLSEnv.sh" >> /u01/oracle/.bash_profile
RUN unzip $WLS_PKG
RUN $JAVA_HOME/bin/java -Xmx1024m -jar /u01/app/oracle/$WLS_JAR -silent -responseFile /u01/app/oracle/wls.rsp -invPtrLoc /u01/app/oracle/oraInst.loc > install.log
RUN rm -f $WLS_PKG
RUN . $WLS_HOME/server/bin/setWLSEnv.sh && java weblogic.version
RUN java weblogic.WLST -skipWLSModuleScanning create_basedomain.py
#end of file
创建如下图像
docker build -f Dockerfile-weblogic12c.2 --tag="weblogic12c:v2" /var/docker-projects
像下面一样启动容器
docker run -d -p 0.0.0.0:7001:7001 -it weblogic12c:v2 bash
像下面一样启动Weblogic
docker exec -it <container id> bash
手动登录到容器并执行./startWeblogic.sh
root@osboxes:/var/docker-projects# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
20f249affaa9 weblogic12c:v2 "/bin/bash" 4 hours ago Up 14 minutes 0.0.0.0:7001->7001/tcp infallible_poincare
按如下所示测试了URL。
root@osboxes:/var/docker-projects# curl -Is http://172.17.0.2:7001/
root@osboxes:/var/docker-projects# echo $?
7
Weblogic已在容器内启动并运行。
<Apr 1, 2019 6:15:59 PM UTC> <Notice> <Security> <BEA-090947> <Security post-initializing using security realm: myrealm> <Apr 1, 2019 6:16:07 PM UTC> <Notice> <Security> <BEA-090082> <Security initialized using administrative security realm: myrealm> <Apr 1, 2019 6:16:22 PM UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY.> <Apr 1, 2019 6:16:22 PM UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING.> <Apr 1, 2019 6:16:23 PM UTC> <Notice> <Log Management> <BEA-170036> <The Logging monitoring service timer has started to check for logged message counts every 30 seconds.> <Apr 1, 2019 6:16:26 PM UTC> <Notice> <Log Management> <BEA-170027> <The server has successfully established a connection with the Domain level Diagnostic Service.> <Apr 1, 2019 6:16:27 PM UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN.> <Apr 1, 2019 6:16:27 PM UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING.> <Apr 1, 2019 6:16:28 PM UTC> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, snmp, http.> <Apr 1, 2019 6:16:28 PM UTC> <Notice> <WebLogicServer> <BEA-000331> <Started the WebLogic Server Administration Server "adminserver" for domain "verdomain" running in development mode.> <Apr 1, 2019 6:16:28 PM UTC> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, snmp, http.> <Apr 1, 2019 6:16:28 PM UTC> <Notice> <WebLogicServer> <BEA-000360> <The server started in RUNNING mode.> <Apr 1, 2019 6:16:28 PM UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING.>
容器的IP地址和接口详细信息。
[oracle@20f249affaa9 oracle]$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
4: eth0@if5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
valid_lft forever preferred_lft forever
返回状态,主机不可访问。 IP是容器IP,并尝试从docker主机访问URL。我是通过桥接网络连接的。
该URL在容器内可访问,但在Docker主机中不可访问。
[oracle@20f249affaa9 oracle]$ curl -Is http://localhost:7001/console
HTTP/1.1 200 OK
Connection: close
Date: Mon, 01 Apr 2019 18:49:19 GMT
Content-Length: 416
root@osboxes:/var/docker-projects# curl -Is http://localhost:7001/console
root@osboxes:/var/docker-projects# echo $?
52
请帮助我如何调试Docker网络,这是此问题的根本原因。我做了谷歌,它说我必须使用-p 0.0.0.0:7001:7001或只是-p 7001:7001来显示端口。
答案 0 :(得分:1)
Weblogic配置为仅在localhost
上侦听,这意味着只能在容器中访问它:
<Apr 1, 2019 6:16:28 PM UTC> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, snmp, http.>
您需要更改Weblogic的配置以绑定到0.0.0.0
。之后,您的解决方案应该可以正常工作。