Search code examples
linuxdockerdockerfileportweblogic12c

Application running in docker container not reachable in docker host


I have Ubuntu 18.04 virtual machine in the Windows Operating system. In the virtual machine, docker is installed and it is the docker host. Created an image using Oracle Linux7 to install Weblogic 12 and started the application manually logging to the container. The ports are mapped successfully and Weblogic is running inside the container but it is not accessible in the docker host and outside the docker host. I would like to know if I am missing any configuration and would like to know how to troubleshoot the docker networking to fix this issue.

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

Created the image like below

docker build -f Dockerfile-weblogic12c.2 --tag="weblogic12c:v2" /var/docker-projects

Started the container like below

docker run -d -p 0.0.0.0:7001:7001 -it weblogic12c:v2 bash

Started the Weblogic like below

docker exec -it <container id> bash

Manually logged in to the container and executed ./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

Tested the URL like below.

root@osboxes:/var/docker-projects# curl -Is http://172.17.0.2:7001/
root@osboxes:/var/docker-projects# echo $?
7

Weblogic started and running inside the container.

<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 address of the container and interface details.

[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

The return status, the host is not reachable. The IP is the container IP and trying to hit the URL from the docker host. I am connected using a bridged network.

The URL is accessble inside the container but not in the docker host.

[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

Please help me how to debug the docker networking, root cause for this issue. I did google and it says that I have to use -p 0.0.0.0:7001:7001 or just -p 7001:7001 to expose the port.


Solution

  • Weblogic is configured to listen only on localhost, which means that it is accessible only within a container:

    <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.>
    

    You need to change Weblogic's configuration to be bound on 0.0.0.0. After that your solution should work properly.