Docker实践2:安装Docker及weblogic镜像
安装Docker
以root登录,运行
vi /etc/yum.repos.d/public-yum-ol6.repo,添加如下段落
[ol6_addons]
name=Oracle Linux $releasever Add ons ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
运行yum install docker
在运行过程中因为网络缓慢,可能出现退出情况,再运行一遍,如果遇到yum提示
another app is currently holding the yum lock;waiting for it to exit
可能是系统自动升级正在运行,yum在锁定状态中。
可以通过强制关掉yum进程:
#rm -f /var/run/yum.pid
完成后运行service start docker.
# chkconfig docker on
# service docker status
docker (pid 9044) is running...
添加能直接运行docker权限的用户
# groupadd docker
# service docker restart
# usermod -a -G docker <your_user>
将git构建代码拿到本地
#yum install git
切换回weblogic用户,运行
$ git clone https://github.com/oracle/docker.git
如果网络比较慢的话再来一遍。
Build jre8
docker build -t oracle/serverjre:8 .
[weblogic@k8s-node-1 java-8]$ sudo docker build -t oracle/serverjre:8 . |
Build WebLogic Generic
进入../docker/OracleWebLogic/dockerfiles/12.1.3目录
下载相应的文件包括server-jre-8u73-linux-x64.tar.gz,fmw_12.1.3.0.0_wls.jar,wls1213_dev_update3.zip放入
通过xmanager的xftp.
运行$ sudo sh buildDockerImage.sh -g
-d主要采用_dev的包,构件开发环境。
-g采用generic的包,也就是fmw_12.1.3.0.0_wls.jar包,构建生产环境。
[weblogic@k8s-node-1 dockerfiles]$ sudo sh buildDockerImage.sh -g Checking if required packages are present and valid... fmw_12.1.3.0.0_wls.jar: OK ===================== Building image 'oracle/weblogic:12.1.3-generic' ... Sending build context to Docker daemon 923.2 MB Step 1 : FROM oracle/serverjre:8 ---> 8c0f2aaba6ed Step 2 : MAINTAINER Bruno Borges <bruno.borges@oracle.com> ---> Running in a3be98df73be ---> d3832c5b38c1 Removing intermediate container a3be98df73be Step 3 : ENV ORACLE_HOME /u01/oracle USER_MEM_ARGS "-Djava.security.egd=file:/dev/./urandom" PATH $PATH:/usr/java/default/bin:/u01/oracle/oracle_common/common/bin ---> Running in fb0773b87de2 ---> 49ebdff9c0f2 Removing intermediate container fb0773b87de2 Step 4 : RUN mkdir -p /u01 && chmod a+xr /u01 && useradd -b /u01 -d /u01/oracle -m -s /bin/bash oracle && chown oracle:oracle -R /u01 ---> Running in cb84a302230a ---> 81a0795cb544 Removing intermediate container cb84a302230a Step 5 : ENV FMW_PKG fmw_12.1.3.0.0_wls.jar ---> Running in ba7ab1312206 ---> ddb95b086113 Removing intermediate container ba7ab1312206 Step 6 : COPY $FMW_PKG install.file oraInst.loc /u01/ ---> 95099fd96c30 Removing intermediate container 848ed94e0775 Step 7 : USER oracle ---> Running in e8a160c7caa1 ---> 6e6dfc3527ee Removing intermediate container e8a160c7caa1 Step 8 : RUN $JAVA_HOME/bin/java -jar /u01/$FMW_PKG -ignoreSysPrereqs -novalidation -silent -responseFile /u01/install.file -invPtrLoc /u01/oraInst.loc -jreLoc $JAVA_HOME ORACLE_HOME=$ORACLE_HOME INSTALL_TYPE="WebLogic Server" && rm /u01/$FMW_PKG /u01/oraInst.loc /u01/install.file ---> Running in 7e844f2f164b Launcher log file is /tmp/OraInstall2017-05-08_01-43-40AM/launcher2017-05-08_01-43-40AM.log. Extracting files............. Starting Oracle Universal InstallerChecking if CPU speed is above 300 MHz. Actual 2494.162 MHz Passed Checking swap space: must be greater than 512 MB. Actual 839676 MB Passed Checking if this platform requires a 64-bit JVM. Actual 64 Passed (64-bit not required) Checking temp space: must be greater than 300 MB. Actual 8146 MB Passed Preparing to launch the Oracle Universal Installer from /tmp/OraInstall2017-05-08_01-43-40AM Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0 Log: /tmp/OraInstall2017-05-08_01-43-40AM/install2017-05-08_01-43-40AM.log Setting ORACLE_HOME to /u01/oracle Setting INSTALL_TYPE to WebLogic Server Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. Reading response file.. Validations are disabled for this session. Verifying data...... Copying Files... You can find the log of this install session at: /tmp/OraInstall2017-05-08_01-43-40AM/install2017-05-08_01-43-40AM.log -----------20%----------40%----------60%----------80%--------100%The installation of Oracle Fusion Middleware 12c WebLogic Server and Coherence 12.1.3.0.0 completed successfully. Logs successfully copied to /u01/oracle/.inventory/logs. ---> 7588fb8b1ea1 Removing intermediate container 7e844f2f164b Step 9 : WORKDIR $ORACLE_HOME ---> Running in 2653c76fc994 ---> fc3cfaae5e57 Removing intermediate container 2653c76fc994 Step 10 : CMD bash ---> Running in f4b21a3fb17b ---> 5d5e3db57694 Removing intermediate container f4b21a3fb17b Successfully built 5d5e3db57694 WebLogic Docker Image for 'generic' version 12.1.3 is ready to be extended: --> oracle/weblogic:12.1.3-generic Build completed in 210 seconds. |
如果sudo出错,解决办法:
以root用户修改/etc/sudoer 文件属性为root可修改,并在root ALL 行下添加 weblogic ALL(类似root行)
# chmod u+w sudoers
# vi sudoers
添加 weblogic ALL=(ALL) ALL
通过docker images查看本地的镜像
建立一个空域的weblogic container
进入sample目录下1213-domain目录,修改脚本,让上面的域基于generic来构件,然后运行
docker build -t 1213-domain . 或者是
sudo docker build -t 1213-domain --build-arg ADMIN_PASSWORD=welcome1 .
[weblogic@k8s-node-1 1213-domain]$ sudo docker build -t 1213-domain --build-arg ADMIN_PASSWORD=welcome1 . Initializing WebLogic Scripting Tool (WLST) ... Welcome to WebLogic Server Administration Scripting Shell Type help() for help on available commands domain_name : [base_domain]
---> d35626c7b868 |
运行容器
docker run -d 1213-domain
因为当前启动命令为startWebLogic.sh,所以通过logs可以看到weblogic启动日志.
此外还有另外两种启动方式:
docker run -d --name wlsadmin --hostname wlsadmin -p 8001:8001 1213-domain
docker run -d -p 8001:8001 --name=wlsadmin 1213-domain startWebLogic.sh
docker logs $container id
docker inspect <container_id> | grep "IPAddress"
然后运行http://172.17.0.1:8001/console,进入weblogic管理控制台(weblogic/welcome1)
修改容器,部署一个helloworld的应用,修改完commit
sudo docker commit -m "Added HelloWorld Application" -a "Eric Nie" 1a4f7376802f823ce71015a232b85810db17eec38ed54670d1ca06fb4f0e750e 1213-helloworld:v1 |