【系列5】使用Dockerfile创建带weblogic的Centos Docker镜像
? ?Weblogic是一個(gè)基于Java EE架構(gòu)的中間件(應(yīng)用服務(wù)器),WebLogic由Oracle公司維護(hù)。
? ?WebLogic是用于開(kāi)發(fā)、集成、部署和管理大型分布式Web應(yīng)用、網(wǎng)絡(luò)應(yīng)用和數(shù)據(jù)庫(kù)應(yīng)用的Java應(yīng)用服務(wù)器。是商業(yè)市場(chǎng)上最主要的Java (J2EE)應(yīng)用服務(wù)器軟件之一,也是世界上第一個(gè)成功商業(yè)化的J2EE應(yīng)用服務(wù)器。
? ?與Tomcat不同的是,Weblogic是一個(gè)商業(yè)軟件,所以需要有授權(quán)才能使用。不過(guò),Oracle公司允許開(kāi)發(fā)者在開(kāi)發(fā)模式下使用Weblogic。如果開(kāi)發(fā)者需要在生產(chǎn)環(huán)境中使用Weblogic,則需要購(gòu)買Oracle公司的正規(guī)商業(yè)授權(quán)。Weblogic的安裝軟件可以到Oracle的官方網(wǎng)站下載。
? ?
? ?Weblogic的基本概念:
? ?◆ Weblogic域:
? ?weblogic域是作為單元進(jìn)行管理的一組相關(guān)的WebLog服務(wù)器資源。一個(gè)域包含一個(gè)或多個(gè)WebLogic服務(wù)器實(shí)例,這些實(shí)例可以是群集實(shí)例、非群集實(shí)例,或者群集與非群集實(shí)例的組合。一個(gè)域可以包含多個(gè)群集。域還包含部署在域中的應(yīng)用程序組件、此域中的這些應(yīng)用程序組件和服務(wù)器實(shí)例所需的資源和服務(wù)。應(yīng)用程序和服務(wù)器實(shí)例使用的資源和服務(wù)示例包括計(jì)算機(jī)定義、可選網(wǎng)絡(luò)通道、連接器和啟動(dòng)類。 ?
? ?◆ Administration服務(wù)器
? ?域中包含一個(gè)特殊的WebLogic服務(wù)器實(shí)例,叫做Administration服務(wù)器,這是用戶配置、管理域中所有資源的核心。
? ?◆ Manager服務(wù)器
? ?通常,稱加入Domain的其他實(shí)例為Managed服務(wù)器,所有的Web應(yīng)用、EJB、Web服務(wù)和其他資源都部署在這些服務(wù)器上。
? ? 一個(gè)典型的Weblogic部署應(yīng)該如圖11-4所示。
? ?如果要使用常規(guī)的administrator +node的方式部署,就需要在run.sh腳本中分別寫(xiě)出administrator服務(wù)器和node服務(wù)器的啟動(dòng)腳本。這樣做的優(yōu)點(diǎn)是:可以使用Weblogic的集群、同步等概念。部署一個(gè)集群應(yīng)用程序,只需要安裝一次應(yīng)用到集群上即可。
? ? 缺點(diǎn)是:
? ? Docker配置復(fù)雜了。
? ?沒(méi)辦法自動(dòng)擴(kuò)展集群的計(jì)算容量,如需添加節(jié)點(diǎn),需要在administrator上先創(chuàng)建節(jié)點(diǎn),然后再配置新的容器run.sh啟動(dòng)腳本,然后再啟動(dòng)容器。
? ?
? ?推薦將應(yīng)用程序安裝在adminiserver上面,當(dāng)需要擴(kuò)展時(shí)候,啟動(dòng)多個(gè)adminiserver節(jié)點(diǎn)即可,將adminiserver當(dāng)作Managed server使用。這樣做的優(yōu)點(diǎn)和缺點(diǎn)和傳統(tǒng)的部署方法恰恰相反。
? ?
? ?使用docker commit + Dockerfile方式創(chuàng)建鏡像
? ?下面將以weblogic 12.11、jdk 1.6、centos7.4為例子,創(chuàng)建一個(gè)帶有Weblogic服務(wù)的鏡像。
① 準(zhǔn)備工作
? ? 由于Weblogic的安裝、部署部署較為復(fù)雜,筆者將先通過(guò)docker run -ti進(jìn)入容器完成大部分操作,然后通過(guò)docker commit將這個(gè)容器提交為一個(gè)鏡像,最后再進(jìn)一步使用Dcokerfile來(lái)完成最終的Weblogic鏡像創(chuàng)建,對(duì)于一些復(fù)雜鏡像的創(chuàng)建。
? ? 在本地主機(jī)上創(chuàng)建weblogic目錄,從其他主機(jī)上傳jdk和weblogic安裝文件到該目錄下,并創(chuàng)建Dockerfule和run.sh腳本文件:
[root@docker1 ~]# mkdir weblogic_jdk1.6
[root@docker1 ~]# cd ?weblogic_jdk1.6/
[root@docker1 weblogic_jdk1.6]# touch Dockerfile run.sh ? ??
[root@docker1 weblogic_jdk1.6]# rz -y
......
[root@docker1 weblogic_jdk1.6]# chmod 755 jdk-6u45-linux-x64.bin
[root@docker1 weblogic_jdk1.6]# ./jdk-6u45-linux-x64.bin
......
[root@docker1 weblogic_jdk1.6]# ls
Dockerfile ?jdk1.6.0_45 ?jdk-6u45-linux-x64.bin ?run.sh ?wls1211_generic.jar
② 安裝Weblogic到容器
? 使用 -v -d -p參數(shù)運(yùn)行之前創(chuàng)建的sshd_dockerfile鏡像:
[root@docker1 ~]# docker run -d -v /root/weblogic_jdk1.6/wls1211_generic.jar:/wls1211_generic.jar -v /root/weblogic_jdk1.6/jdk1.6.0_45:/jdk -P sshd:centos
26bbe0516fda340bf3b9f41d604bf77a3a3fa52f9f3da01e97326c4881148a1c
?在宿主主機(jī)查看容器的ssh端口映射情況,可以看到映射到了本地的49159端口:
[root@docker1 ~]# docker ps
CONTAINER ID ? ? ? ?IMAGE ? ? ? ? ? ? ? COMMAND ? ? ? ? ? ? CREATED ? ? ? ? ? ? STATUS ? ? ? ? ? ? ?PORTS ? ? ? ? ? ? ? ? ? NAMES
26bbe0516fda ? ? ? ?sshd:centos ? ? ? ? "/run.sh" ? ? ? ? ? 9 seconds ago ? ? ? Up 9 seconds ? ? ? ?0.0.0.0:32769->22/tcp ? fervent_liskov
[root@docker1 ~]# ssh 127.0.0.1 -p 32769
The authenticity of host '[127.0.0.1]:32769 ([127.0.0.1]:32769)' can't be established.
RSA key fingerprint is SHA256:H+F+JE+nuPXMpk5fYDVNYc25mrSdTNtjDAejT9eHgMw.
RSA key fingerprint is MD5:16:f2:b9:2c:d7:a5:55:70:72:2c:88:93:e8:aa:49:3d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[127.0.0.1]:32769' (RSA) to the list of known hosts.
[root@26bbe0516fda ~]# cd /
[root@26bbe0516fda /]# ls -lh
total 997M
-rw-r--r--. ? 1 root root ?16K Sep 11 15:53 anaconda-post.log
lrwxrwxrwx. ? 1 root root ? ?7 Sep 11 15:51 bin -> usr/bin
drwxr-xr-x. ? 5 root root ?360 Dec 13 09:40 dev
drwxr-xr-x. ?49 root root 4.0K Dec 13 09:40 etc
drwxr-xr-x. ? 2 root root ? ?6 Nov ?5 ?2016 home
drwxr-xr-x. ? 8 root root ?176 Mar 26 ?2013 jdk
lrwxrwxrwx. ? 1 root root ? ?7 Sep 11 15:51 lib -> usr/lib
lrwxrwxrwx. ? 1 root root ? ?9 Sep 11 15:51 lib64 -> usr/lib64
drwx------. ? 2 root root ? ?6 Sep 11 15:51 lost+found
drwxr-xr-x. ? 2 root root ? ?6 Nov ?5 ?2016 media
drwxr-xr-x. ? 2 root root ? ?6 Nov ?5 ?2016 mnt
drwxr-xr-x. ? 2 root root ? ?6 Nov ?5 ?2016 opt
dr-xr-xr-x. 137 root root ? ?0 Dec 13 09:40 proc
dr-xr-x---. ? 3 root root ?149 Nov 21 09:24 root
drwxr-xr-x. ?12 root root ?173 Dec 13 09:40 run
-rwxr-xr-x. ? 1 root root ? 30 Nov 13 08:50 run.sh
lrwxrwxrwx. ? 1 root root ? ?8 Sep 11 15:51 sbin -> usr/sbin
drwxr-xr-x. ? 2 root root ? ?6 Nov ?5 ?2016 srv
dr-xr-xr-x. ?13 root root ? ?0 Dec 12 16:12 sys
drwxrwxrwt. ? 7 root root ?132 Sep 11 15:53 tmp
drwxr-xr-x. ?13 root root ?155 Sep 11 15:51 usr
drwxr-xr-x. ?18 root root ?238 Sep 11 15:53 var
-rw-r--r--. ? 1 root root 997M Dec 12 14:20 wls1211_generic.jar
在這里使用命令行模式,在容器內(nèi)進(jìn)行weblogic的安裝:
以console模式啟動(dòng)weblogic安裝,默認(rèn)使用圖形界面安裝:
[root@26bbe0516fda /]# ./jdk/bin/java -jar wls1211_generic.jar -mode=console
Extracting 0%....................................................................................................100%
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Welcome:
--------
This installer will guide you through the installation of WebLogic 12.1.1.0.?
Type "Next" or enter to proceed to the next prompt. ?If you want to change data entered previously, type "Previous". ?You may quit the installer at any time by typing "Exit".
Enter [Exit][Next]>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#直接回車
? ?不使用默認(rèn)的安裝位置,我們將weblogic安裝在opt目錄下面:
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Choose Middleware Home Directory:
---------------------------------
? ? "Middleware Home" = [Enter new value or use default?
"/root/Oracle/Middleware"]
Enter new Middleware Home OR [Exit][Previous][Next]> /opt/Middleware ? ? ?#輸入安裝目錄
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Choose Middleware Home Directory:
---------------------------------
? ? "Middleware Home" = [/opt/Middleware]
Use above value or select another option:
? ? 1 - Enter new Middleware Home
? ? 2 - Change to default [/root/Oracle/Middleware]
Enter option number to select OR [Exit][Previous][Next]>? ? ? ? ? ? ? ? ?#直接回車
因?yàn)槲覀冞@里使用的授權(quán)時(shí)開(kāi)發(fā)模式的,所以選擇不接收安全更新:
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Register for Security Updates:
------------------------------
Provide your email address for security updates and ?to initiate configuration manager.
? ?1|Email:[]
? ?2|Support Password:[]
? ?3|Receive Security Update:[Yes]
Enter index number to select OR [Exit][Previous][Next]> 3 ? ? ? ? ? ? ? ? ?#選擇3接受安全更新 ? ? ?
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Register for Security Updates:
------------------------------
Provide your email address for security updates and ?to initiate configuration manager.
? ? "Receive Security Update:" = [Enter new value or use default "Yes"]
Enter [Yes][No]? no ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #選擇不接受更新升級(jí)
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Register for Security Updates:
------------------------------
Provide your email address for security updates and ?to initiate configuration manager.
? ? "Receive Security Update:" = [Enter new value or use default "Yes"]
? ? ** Do you wish to bypass initiation of the configuration manager and
? ? ** ?remain uninformed of critical security issues in your configuration?
Enter [Yes][No]??yes ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #輸入yes
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Register for Security Updates:
------------------------------
Provide your email address for security updates and ?to initiate configuration manager.
? ?1|Email:[]
? ?2|Support Password:[]
? ?3|Receive Security Update:[No]
Enter index number to select OR [Exit][Previous][Next]>? ? ? ? ? ? ?#在這里選擇默認(rèn)的組件:
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Register for Security Updates:
------------------------------
Provide your email address for security updates and ?to initiate configuration manager.
? ?1|Email:[]
? ?2|Support Password:[]
? ?3|Receive Security Update:[No]
Enter index number to select OR [Exit][Previous][Next]>?
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Choose Install Type:
--------------------
Select the type of installation you wish to perform.?
?->1|Typical
? ? | ?Install the following product(s) and component(s):
? ? | - WebLogic Server
? ? | - Oracle Coherence
? ?2|Custom
? ? | ?Choose software products and components to install and perform optional?
? ? |configuration.
Enter index number to select OR [Exit][Previous][Next]> ? ??
因?yàn)槲覀兪窃趈dk目錄下使用Java,所以weblogic記住了我們的jdk位置,選擇使用默認(rèn)的jdk位置,后面還需要選擇產(chǎn)品安裝目錄,之后即開(kāi)始安裝過(guò)程。
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
JDK Selection (Any * indicates Oracle Supplied VM):
---------------------------------------------------
JDK(s) chosen will be installed. ?Defaults will be used in script string-substitution if installed.
? ?1|Add Local Jdk
? ?2|/jdk[x]
? ?*Estimated size of installation: ?589.7 MB
Enter 1 to add or >= 2 to toggle selection ?OR [Exit][Previous][Next]>?
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Choose Product Installation Directories:
----------------------------------------
Middleware Home Directory: [/opt/Middleware]
Product Installation Directories:
? ?1|WebLogic Server: [/opt/Middleware/wlserver_12.1]
? ?2|Oracle Coherence: [/opt/Middleware/coherence_3.7]
Enter index number to select OR [Exit][Previous][Next]>?
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
The following Products and JDKs will be installed:
--------------------------------------------------
? ? WebLogic Platform 12.1.1.0
? ? |_____WebLogic Server
? ? | ? ?|_____Core Application Server
? ? | ? ?|_____Administration Console
? ? | ? ?|_____Configuration Wizard and Upgrade Framework
? ? | ? ?|_____Web 2.0 HTTP Pub-Sub Server
? ? | ? ?|_____WebLogic SCA
? ? | ? ?|_____WebLogic JDBC Drivers
? ? | ? ?|_____Third Party JDBC Drivers
? ? | ? ?|_____WebLogic Server Clients
? ? | ? ?|_____Xquery Support
? ? | ? ?|_____Evaluation Database
? ? |_____Oracle Coherence
? ? ? ? ?|_____Coherence Product Files
? ? *Estimated size of installation: 589.9 MB
Enter [Exit][Previous][Next]>?
Dec 13, 2017 6:01:33 PM java.util.prefs.FileSystemPreferences$2 run
INFO: Created user preferences directory.
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Installing files..
0% ? ? ? ? ?25% ? ? ? ? ?50% ? ? ? ? ?75% ? ? ? ? ?100%
[------------|------------|------------|------------]
[***************************************************]
Performing String Substitutions...?
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Configuring OCM...
0% ? ? ? ? ?25% ? ? ? ? ?50% ? ? ? ? ?75% ? ? ? ? ?100%
[------------|------------|------------|------------]
[***************************************************]
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Installing Patches...
0% ? ? ? ? ?25% ? ? ? ? ?50% ? ? ? ? ?75% ? ? ? ? ?100%
[------------|------------|------------|------------]
[***************************************************]
Creating Domains...
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Installation Complete
Congratulations! Installation is complete.
Press [Enter] to continue or type [Exit]>?
<-------------------- Oracle Installer - WebLogic 12.1.1.0 ------------------->
Clean up process in progress ...
完成以上步驟,容器已成功安裝weblogic服務(wù)。
③ 創(chuàng)建節(jié)點(diǎn):
接下來(lái),將創(chuàng)建默認(rèn)的weblogic域和Adminserver節(jié)點(diǎn):
同樣使用console模式啟動(dòng)安裝,并選擇新建weblogic域:
[root@26bbe0516fda /]# cd /opt/Middleware/wlserver_12.1/common/bin/
[root@26bbe0516fda bin]# ls
commEnv.sh ? ? ? ? config.sh ?setPatchEnv.sh ?startManagedWebLogic.sh ?unpack.sh ? wlscontrol.sh ? wlst.sh
config_builder.sh ?pack.sh ? ?startDerby.sh ? stopDerby.sh ? ? ? ? ? ? upgrade.sh ?wlsifconfig.sh
[root@26bbe0516fda bin]# ./config.sh -mode=console
<------------------- Fusion Middleware Configuration Wizard ------------------>
Welcome:
--------
Choose between creating and extending a domain. Based on your selection,?
the Configuration Wizard guides you through the steps to generate a new or?
extend an existing domain.
?->1|Create a new WebLogic domain
? ? | ? ?Create a WebLogic domain in your projects directory. ?
? ?2|Extend an existing WebLogic domain
? ? | ? ?Use this option to add new components to an existing domain and modify ? ? |configuration settings.?
Enter index number to select OR [Exit][Next]>?
<------------------- Fusion Middleware Configuration Wizard ------------------>
Select Domain Source:
---------------------
Select the source from which the domain will be created. You can create the?
domain by selecting from the required components or by selecting from a?
list of existing domain templates.
?->1|Choose Weblogic Platform components
? ? | ? ?You can choose the Weblogic component(s) that you want supported in?
? ? |your domain.?
? ?2|Choose custom template
? ? | ? ?Choose this option if you want to use an existing ?template. This?
? ? |could be a custom created template using the Template Builder.?
Enter index number to select OR [Exit][Previous][Next]>?
選擇默認(rèn)的weblogic組件:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Application Template Selection:
-------------------------------
? ? Available Templates
? ? |_____Basic WebLogic Server Domain - 12.1.1.0 [wlserver_12.1]x
? ? |_____Basic WebLogic SIP Server Domain - 12.1.1.0 [wlserver_12.1] [2]?
? ? |_____WebLogic Advanced Web Services for JAX-RPC Extension - 12.1.1.0 [wlserver_12.1] [3]?
? ? |_____WebLogic Advanced Web Services for JAX-WS Extension - 12.1.1.0 [wlserver_12.1] [4]?
Enter number exactly as it appears in brackets to toggle selection OR [Exit][Previous][Next]>?
設(shè)置新建的域名:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Edit Domain Information:
------------------------
? ? | ?Name ?| ? ?Value ? ?|
? ?_|________|_____________|
? ?1| *Name: | base_domain |
Enter value for "Name" OR [Exit][Previous][Next]>?
使用默認(rèn)的安裝位置:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Select the target domain directory for this domain:
---------------------------------------------------
? ? "Target Location" = [Enter new value or use default?
"/opt/Middleware/user_projects/domains"]
Enter new Target Location OR [Exit][Previous][Next]>?
設(shè)置用戶名和密碼:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure Administrator User Name and Password:
-----------------------------------------------
Create a user to be assigned to the Administrator role. This user is the?
default administrator used to start development mode servers.
? ? | ? ? ? ? ?Name ? ? ? ? ? | ? ? ? ? ? ? ? ? ?Value ? ? ? ? ? ? ? ? ?|
? ?_|_________________________|_________________________________________|
? ?1| ? ? ? ? *Name: ? ? ? ? ?| ? ? ? ? ? ? ? ?weblogic ? ? ? ? ? ? ? ? |
? ?2| ? ? *User password: ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
? ?3| *Confirm user password: | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
? ?4| ? ? ?Description: ? ? ? | This user is the default administrator. |
Use above value or select another option:
? ? 1 - Modify "Name"
? ? 2 - Modify "User password"
? ? 3 - Modify "Confirm user password"
? ? 4 - Modify "Description"
Enter option number to select OR [Exit][Previous][Next]>?3
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure Administrator User Name and Password:
-----------------------------------------------
Create a user to be assigned to the Administrator role. This user is the?
default administrator used to start development mode servers.
? ? "*Confirm user password:" = []
Enter new *Confirm user password: OR [Exit][Reset][Accept]>?weblogic_test
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure Administrator User Name and Password:
-----------------------------------------------
Create a user to be assigned to the Administrator role. This user is the?
default administrator used to start development mode servers.
? ? | ? ? ? ? ?Name ? ? ? ? ? | ? ? ? ? ? ? ? ? ?Value ? ? ? ? ? ? ? ? ?|
? ?_|_________________________|_________________________________________|
? ?1| ? ? ? ? *Name: ? ? ? ? ?| ? ? ? ? ? ? ? ?weblogic ? ? ? ? ? ? ? ? |
? ?2| ? ? *User password: ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
? ?3| *Confirm user password: | ? ? ? ? ? ? ?************* ? ? ? ? ? ? ?|
? ?4| ? ? ?Description: ? ? ? | This user is the default administrator. |
Use above value or select another option:
? ? 1 - Modify "Name"
? ? 2 - Modify "User password"
? ? 3 - Modify "Confirm user password"
? ? 4 - Modify "Description"
? ? 5 - Discard Changes
Enter option number to select OR [Exit][Previous][Next]>?2
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure Administrator User Name and Password:
-----------------------------------------------
Create a user to be assigned to the Administrator role. This user is the?
default administrator used to start development mode servers.
? ? "*User password:" = []
Enter new *User password: OR [Exit][Reset][Accept]>?weblogic_test
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure Administrator User Name and Password:
-----------------------------------------------
Create a user to be assigned to the Administrator role. This user is the?
default administrator used to start development mode servers.
? ? | ? ? ? ? ?Name ? ? ? ? ? | ? ? ? ? ? ? ? ? ?Value ? ? ? ? ? ? ? ? ?|
? ?_|_________________________|_________________________________________|
? ?1| ? ? ? ? *Name: ? ? ? ? ?| ? ? ? ? ? ? ? ?weblogic ? ? ? ? ? ? ? ? |
? ?2| ? ? *User password: ? ? | ? ? ? ? ? ? ?************* ? ? ? ? ? ? ?|
? ?3| *Confirm user password: | ? ? ? ? ? ? ?************* ? ? ? ? ? ? ?|
? ?4| ? ? ?Description: ? ? ? | This user is the default administrator. |
Use above value or select another option:
? ? 1 - Modify "Name"
? ? 2 - Modify "User password"
? ? 3 - Modify "Confirm user password"
? ? 4 - Modify "Description"
? ? 5 - Discard Changes
Enter option number to select OR [Exit][Previous][Next]>?
根據(jù)授權(quán),使用開(kāi)發(fā)模式或生產(chǎn)模式:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Domain Mode Configuration:
--------------------------
Enable Development or Production Mode for this domain.?
?->1|Development Mode
? ?2|Production Mode
Enter index number to select OR [Exit][Previous][Next]> 1 ? ? ?#選擇開(kāi)發(fā)模式
<------------------- Fusion Middleware Configuration Wizard ------------------>
Java SDK Selection:
-------------------
?->1|Sun SDK 1.6.0_45 @ /jdk
? ?2|Other Java SDK
Enter index number to select OR [Exit][Previous][Next]>?
選擇只安裝一個(gè)administration server,其他服務(wù)的安裝跟這個(gè)一樣:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Select Optional Configuration:
------------------------------
? ?1|Administration Server [ ]
? ?2|Managed Servers, Clusters and Machines [ ]
? ?3|RDBMS Security Store [ ]
Enter index number to select OR [Exit][Previous][Next]>?1
<------------------- Fusion Middleware Configuration Wizard ------------------>
Select Optional Configuration:
------------------------------
? ?1|Administration Server [x]
? ?2|Managed Servers, Clusters and Machines [ ]
? ?3|RDBMS Security Store [ ]
Enter index number to select OR [Exit][Previous][Next]>?
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure the Administration Server:
------------------------------------
Each WebLogic Server domain must have one Administration Server. The?
Administration Server is used to perform administrative tasks.
? ? | ? ? ? Name ? ? ? | ? ? ? ?Value ? ? ? ?|
? ?_|__________________|_____________________|
? ?1| ? ? ?*Name: ? ? ?| ? ? AdminServer ? ? |
? ?2| *Listen address: | All Local Addresses |
? ?3| ? Listen port: ? | ? ? ? ?7001 ? ? ? ? |
? ?4| SSL listen port: | ? ? ? ? N/A ? ? ? ? |
? ?5| ? SSL enabled: ? | ? ? ? ?false ? ? ? ?|
Use above value or select another option:
? ? 1 - Modify "Name"
? ? 2 - Modify "Listen address"
? ? 3 - Modify "Listen port"
? ? 4 - Modify "SSL enabled"
Enter option number to select OR [Exit][Previous][Next]>?
<------------------- Fusion Middleware Configuration Wizard ------------------>
Creating Domain...
0% ? ? ? ? ?25% ? ? ? ? ?50% ? ? ? ? ?75% ? ? ? ? ?100%
[------------|------------|------------|------------]
[***************************************************]
**** Domain Created Successfully! ****
[root@26bbe0516fda bin]# ./config.sh -mode=console
<------------------- Fusion Middleware Configuration Wizard ------------------>
Welcome:
--------
Choose between creating and extending a domain. Based on your selection,?
the Configuration Wizard guides you through the steps to generate a new or?
extend an existing domain.
?->1|Create a new WebLogic domain
? ? | ? ?Create a WebLogic domain in your projects directory. ?
? ?2|Extend an existing WebLogic domain
? ? | ? ?Use this option to add new components to an existing domain and modify ? ? |configuration settings.?
Enter index number to select OR [Exit][Next]>?
<------------------- Fusion Middleware Configuration Wizard ------------------>
Select Domain Source:
---------------------
Select the source from which the domain will be created. You can create the?
domain by selecting from the required components or by selecting from a?
list of existing domain templates.
?->1|Choose Weblogic Platform components
? ? | ? ?You can choose the Weblogic component(s) that you want supported in?
? ? |your domain.?
? ?2|Choose custom template
? ? | ? ?Choose this option if you want to use an existing ?template. This?
? ? |could be a custom created template using the Template Builder.?
Enter index number to select OR [Exit][Previous][Next]>?
選擇默認(rèn)的weblogic組件:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Application Template Selection:
-------------------------------
? ? Available Templates
? ? |_____Basic WebLogic Server Domain - 12.1.1.0 [wlserver_12.1]x
? ? |_____Basic WebLogic SIP Server Domain - 12.1.1.0 [wlserver_12.1] [2]?
? ? |_____WebLogic Advanced Web Services for JAX-RPC Extension - 12.1.1.0 [wlserver_12.1] [3]?
? ? |_____WebLogic Advanced Web Services for JAX-WS Extension - 12.1.1.0 [wlserver_12.1] [4]?
Enter number exactly as it appears in brackets to toggle selection OR [Exit][Previous][Next]>?
設(shè)置新建的域名:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Edit Domain Information:
------------------------
? ? | ?Name ?| ? ?Value ? ?|
? ?_|________|_____________|
? ?1| *Name: | base_domain |
Enter value for "Name" OR [Exit][Previous][Next]>?
使用默認(rèn)的安裝位置:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Select the target domain directory for this domain:
---------------------------------------------------
? ? "Target Location" = [Enter new value or use default?
"/opt/Middleware/user_projects/domains"]
Enter new Target Location OR [Exit][Previous][Next]>?
設(shè)置用戶名和密碼:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure Administrator User Name and Password:
-----------------------------------------------
Create a user to be assigned to the Administrator role. This user is the?
default administrator used to start development mode servers.
? ? | ? ? ? ? ?Name ? ? ? ? ? | ? ? ? ? ? ? ? ? ?Value ? ? ? ? ? ? ? ? ?|
? ?_|_________________________|_________________________________________|
? ?1| ? ? ? ? *Name: ? ? ? ? ?| ? ? ? ? ? ? ? ?weblogic ? ? ? ? ? ? ? ? |
? ?2| ? ? *User password: ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
? ?3| *Confirm user password: | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
? ?4| ? ? ?Description: ? ? ? | This user is the default administrator. |
Use above value or select another option:
? ? 1 - Modify "Name"
? ? 2 - Modify "User password"
? ? 3 - Modify "Confirm user password"
? ? 4 - Modify "Description"
Enter option number to select OR [Exit][Previous][Next]>?3
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure Administrator User Name and Password:
-----------------------------------------------
Create a user to be assigned to the Administrator role. This user is the?
default administrator used to start development mode servers.
? ? "*Confirm user password:" = []
Enter new *Confirm user password: OR [Exit][Reset][Accept]>?weblogic_test
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure Administrator User Name and Password:
-----------------------------------------------
Create a user to be assigned to the Administrator role. This user is the?
default administrator used to start development mode servers.
? ? | ? ? ? ? ?Name ? ? ? ? ? | ? ? ? ? ? ? ? ? ?Value ? ? ? ? ? ? ? ? ?|
? ?_|_________________________|_________________________________________|
? ?1| ? ? ? ? *Name: ? ? ? ? ?| ? ? ? ? ? ? ? ?weblogic ? ? ? ? ? ? ? ? |
? ?2| ? ? *User password: ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
? ?3| *Confirm user password: | ? ? ? ? ? ? ?************* ? ? ? ? ? ? ?|
? ?4| ? ? ?Description: ? ? ? | This user is the default administrator. |
Use above value or select another option:
? ? 1 - Modify "Name"
? ? 2 - Modify "User password"
? ? 3 - Modify "Confirm user password"
? ? 4 - Modify "Description"
? ? 5 - Discard Changes
Enter option number to select OR [Exit][Previous][Next]>?2
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure Administrator User Name and Password:
-----------------------------------------------
Create a user to be assigned to the Administrator role. This user is the?
default administrator used to start development mode servers.
? ? "*User password:" = []
Enter new *User password: OR [Exit][Reset][Accept]>?weblogic_test
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure Administrator User Name and Password:
-----------------------------------------------
Create a user to be assigned to the Administrator role. This user is the?
default administrator used to start development mode servers.
? ? | ? ? ? ? ?Name ? ? ? ? ? | ? ? ? ? ? ? ? ? ?Value ? ? ? ? ? ? ? ? ?|
? ?_|_________________________|_________________________________________|
? ?1| ? ? ? ? *Name: ? ? ? ? ?| ? ? ? ? ? ? ? ?weblogic ? ? ? ? ? ? ? ? |
? ?2| ? ? *User password: ? ? | ? ? ? ? ? ? ?************* ? ? ? ? ? ? ?|
? ?3| *Confirm user password: | ? ? ? ? ? ? ?************* ? ? ? ? ? ? ?|
? ?4| ? ? ?Description: ? ? ? | This user is the default administrator. |
Use above value or select another option:
? ? 1 - Modify "Name"
? ? 2 - Modify "User password"
? ? 3 - Modify "Confirm user password"
? ? 4 - Modify "Description"
? ? 5 - Discard Changes
Enter option number to select OR [Exit][Previous][Next]>?
根據(jù)授權(quán),使用開(kāi)發(fā)模式或生產(chǎn)模式:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Domain Mode Configuration:
--------------------------
Enable Development or Production Mode for this domain.?
?->1|Development Mode
? ?2|Production Mode
Enter index number to select OR [Exit][Previous][Next]> 2
<------------------- Fusion Middleware Configuration Wizard ------------------>
Java SDK Selection:
-------------------
?->1|Sun SDK 1.6.0_45 @ /jdk
? ?2|Other Java SDK
Enter index number to select OR [Exit][Previous][Next]>?
選擇只安裝一個(gè)administration server,其他服務(wù)的安裝跟這個(gè)一樣:
<------------------- Fusion Middleware Configuration Wizard ------------------>
Select Optional Configuration:
------------------------------
? ?1|Administration Server [ ]
? ?2|Managed Servers, Clusters and Machines [ ]
? ?3|RDBMS Security Store [ ]
Enter index number to select OR [Exit][Previous][Next]>?1
<------------------- Fusion Middleware Configuration Wizard ------------------>
Select Optional Configuration:
------------------------------
? ?1|Administration Server [x]
? ?2|Managed Servers, Clusters and Machines [ ]
? ?3|RDBMS Security Store [ ]
Enter index number to select OR [Exit][Previous][Next]>?
<------------------- Fusion Middleware Configuration Wizard ------------------>
Configure the Administration Server:
------------------------------------
Each WebLogic Server domain must have one Administration Server. The?
Administration Server is used to perform administrative tasks.
? ? | ? ? ? Name ? ? ? | ? ? ? ?Value ? ? ? ?|
? ?_|__________________|_____________________|
? ?1| ? ? ?*Name: ? ? ?| ? ? AdminServer ? ? |
? ?2| *Listen address: | All Local Addresses |
? ?3| ? Listen port: ? | ? ? ? ?7001 ? ? ? ? |
? ?4| SSL listen port: | ? ? ? ? N/A ? ? ? ? |
? ?5| ? SSL enabled: ? | ? ? ? ?false ? ? ? ?|
Use above value or select another option:
? ? 1 - Modify "Name"
? ? 2 - Modify "Listen address"
? ? 3 - Modify "Listen port"
? ? 4 - Modify "SSL enabled"
Enter option number to select OR [Exit][Previous][Next]>?
<------------------- Fusion Middleware Configuration Wizard ------------------>
Creating Domain...
0% ? ? ? ? ?25% ? ? ? ? ?50% ? ? ? ? ?75% ? ? ? ? ?100%
[------------|------------|------------|------------]
[***************************************************]
**** Domain Created Successfully! ****
④ 配置Weblogic
首先,修改Weblogic的一些環(huán)境變量:
[root@26bbe0516fda bin]# cd /opt/Middleware/user_projects/domains/base_domain/
[root@26bbe0516fda base_domain]# ls
autodeploy ?bin ?config ?console-ext ?fileRealm.properties ?init-info ?lib ?security ?startWebLogic.sh
[root@26bbe0516fda base_domain]# vi bin/s
server_migration/ ? ? ? ?setDomainEnv.sh ? ? ? ? ?startWebLogic.sh ? ? ? ? stopWebLogic.sh ? ? ? ? ?
service_migration/ ? ? ? startManagedWebLogic.sh ?stopManagedWebLogic.sh ?
[root@26bbe0516fda base_domain]# vi bin/setDomainEnv.sh
? ?使用用戶名和密碼啟動(dòng)一次Weblogic之后,會(huì)在/opy/Middleware/user_projects/domains/base_domain下面生產(chǎn)一個(gè)server的文件夾的AdminServer文件夾。
[root@26bbe0516fda AdminServer]# pwd
/opt/Middleware/user_projects/domains/base_domain/servers/AdminServer
[root@26bbe0516fda AdminServer]# mkdir security
[root@26bbe0516fda AdminServer]# ls
cache ?data ?logs ?security ?tmp
[root@26bbe0516fda security]# echo -e 'username=weblogic\npassword=password' >>boot.properties
[root@26bbe0516fda security]# cat boot.properties
username=weblogic
password=password
? ?創(chuàng)建security/boot.properties文件,內(nèi)容如下:
? ?username=weblogic
? ?password=weblogic_test
? ?這樣,再次啟動(dòng)Weblogic時(shí),就不需要輸入密碼了。通過(guò)console的輸出可以看到Weblogic在容器內(nèi)啟動(dòng)成功,并監(jiān)聽(tīng)到7001端口:
? ?
[root@26bbe0516fda AdminServer]# cd ../../../
[root@26bbe0516fda base_domain]# ls
autodeploy ?bin ?config ?console-ext ?fileRealm.properties ?init-info ?lib ?security ?servers ?startWebLogic.sh
[[root@aca388afeddf base_domain]# ./startWebLogic.sh &
[1] 1523
[root@aca388afeddf base_domain]# .
.
JAVA Memory arguments: -Xms256m -Xmx512m -XX:CompileThreshold=8000 -XX:PermSize=128m ?-XX:MaxPermSize=256m
.
WLS Start Mode=Development
.
CLASSPATH=/opt/Middleware/patch_wls1211/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/Middleware/patch_ocp371/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/jdk/lib/tools.jar:/opt/Middleware/wlserver_12.1/server/lib/weblogic_sp.jar:/opt/Middleware/wlserver_12.1/server/lib/weblogic.jar:/opt/Middleware/modules/features/weblogic.server.modules_12.1.1.0.jar:/opt/Middleware/wlserver_12.1/server/lib/webservices.jar:/opt/Middleware/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/opt/Middleware/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar:/opt/Middleware/wlserver_12.1/common/derby/lib/derbyclient.jar:/opt/Middleware/wlserver_12.1/server/lib/xqrl.jar
.
PATH=/opt/Middleware/wlserver_12.1/server/bin:/opt/Middleware/modules/org.apache.ant_1.7.1/bin:/jdk/jre/bin:/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
.
***************************************************
* ?To start WebLogic Server, use a username and ? *
* ?password assigned to an admin-level user. ?For *
* ?server administration, use the WebLogic Server *
* ?console at http://hostname:port/console ? ? ? ?*
***************************************************
starting weblogic with Java version:
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
Starting WLS with line:
/jdk/bin/java -client ? -Xms256m -Xmx512m -XX:CompileThreshold=8000 -XX:PermSize=128m ?-XX:MaxPermSize=256m -Dweblogic.Name=AdminServer -Djava.security.policy=/opt/Middleware/wlserver_12.1/server/lib/weblogic.policy ?-Xverify:none -Djava.endorsed.dirs=/jdk/jre/lib/endorsed:/opt/Middleware/wlserver_12.1/endorsed ?-da -Dplatform.home=/opt/Middleware/wlserver_12.1 -Dwls.home=/opt/Middleware/wlserver_12.1/server -Dweblogic.home=/opt/Middleware/wlserver_12.1/server ? -Dweblogic.management.discover=true ?-Dwlw.iterativeDev= -Dwlw.testConsole= -Dwlw.logErrorsToConsole= -Dweblogic.ext.dirs=/opt/Middleware/patch_wls1211/profiles/default/sysext_manifest_classpath:/opt/Middleware/patch_ocp371/profiles/default/sysext_manifest_classpath ?weblogic.Server
<Dec 29, 2017 3:25:14 PM CST> <Info> <Security> <BEA-090905> <Disabling CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerification=true>
<Dec 29, 2017 3:25:14 PM CST> <Info> <Security> <BEA-090906> <Changing the default Random Number Generator in RSA CryptoJ from ECDRBG to FIPS186PRNG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true>
<Dec 29, 2017 3:25:15 PM CST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) 64-Bit Server VM Version 20.45-b01 from Sun Microsystems Inc..>
<Dec 29, 2017 3:25:15 PM CST> <Info> <Management> <BEA-141107> <Version: WebLogic Server Temporary Patch for 13340309 Thu Feb 16 18:30:21 IST 2012
WebLogic Server Temporary Patch for 13019800 Mon Jan 16 16:53:54 IST 2012
WebLogic Server Temporary Patch for BUG13391585 Thu Feb 02 10:18:36 IST 2012
WebLogic Server Temporary Patch for 13516712 Mon Jan 30 15:09:33 IST 2012
WebLogic Server Temporary Patch for BUG13641115 Tue Jan 31 11:19:13 IST 2012
WebLogic Server Temporary Patch for BUG13603813 Wed Feb 15 19:34:13 IST 2012
WebLogic Server Temporary Patch for 13424251 Mon Jan 30 14:32:34 IST 2012
WebLogic Server Temporary Patch for 13361720 Mon Jan 30 15:24:05 IST 2012
WebLogic Server Temporary Patch for BUG13421471 Wed Feb 01 11:24:18 IST 2012
WebLogic Server Temporary Patch for BUG13657792 Thu Feb 23 12:57:33 IST 2012
WebLogic Server 12.1.1.0 ?Wed Dec 7 08:40:57 PST 2011 1445491 >
<Dec 29, 2017 3:25:17 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING.>
<Dec 29, 2017 3:25:17 PM CST> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool.>
<Dec 29, 2017 3:25:17 PM CST> <Notice> <LoggingService> <BEA-320400> <The log file /opt/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs/AdminServer.log will be rotated. Reopen the log file if tailing has stopped. This can happen on some platforms, such as Windows.>
<Dec 29, 2017 3:25:17 PM CST> <Notice> <LoggingService> <BEA-320401> <The log file has been rotated to /opt/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs/AdminServer.log00011. Log messages will continue to be logged in /opt/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs/AdminServer.log.>
<Dec 29, 2017 3:25:17 PM CST> <Notice> <Log Management> <BEA-170019> <The server log file /opt/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs/AdminServer.log is opened. All server side log events will be written to this file.>
<Dec 29, 2017 3:25:20 PM CST> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.>
<Dec 29, 2017 3:25:25 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY.>
<Dec 29, 2017 3:25:25 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING.>
<Dec 29, 2017 3:25:26 PM CST> <Notice> <LoggingService> <BEA-320400> <The log file /opt/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs/base_domain.log will be rotated. Reopen the log file if tailing has stopped. This can happen on some platforms, such as Windows.>
<Dec 29, 2017 3:25:26 PM CST> <Notice> <LoggingService> <BEA-320401> <The log file has been rotated to /opt/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs/base_domain.log00001. Log messages will continue to be logged in /opt/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs/base_domain.log.>
<Dec 29, 2017 3:25:26 PM CST> <Notice> <Log Management> <BEA-170027> <The server has successfully established a connection with the Domain level Diagnostic Service.>
<Dec 29, 2017 3:25:26 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN.>
<Dec 29, 2017 3:25:26 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING.>
<Dec 29, 2017 3:25:27 PM CST> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on fe80:0:0:0:42:acff:fe11:2:7001 for protocols iiop, t3, ldap, snmp, http.>
<Dec 29, 2017 3:25:27 PM CST> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 172.17.0.2:7001 for protocols iiop, t3, ldap, snmp, http.>
<Dec 29, 2017 3:25:27 PM CST> <Notice> <Server> <BEA-002613> <Channel "Default[2]" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, snmp, http.>
<Dec 29, 2017 3:25:27 PM CST> <Notice> <Server> <BEA-002613> <Channel "Default[3]" is now listening on 0:0:0:0:0:0:0:1:7001 for protocols iiop, t3, ldap, snmp, http.>
<Dec 29, 2017 3:25:27 PM CST> <Notice> <WebLogicServer> <BEA-000331> <Started the WebLogic Server Administration Server "AdminServer" for domain "base_domain" running in development mode.>
<Dec 29, 2017 3:25:27 PM CST> <Warning> <Server> <BEA-002611> <The hostname "localhost", maps to multiple IP addresses: 127.0.0.1, 0:0:0:0:0:0:0:1.>
<Dec 29, 2017 3:25:27 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING.>
<Dec 29, 2017 3:25:27 PM CST> <Notice> <WebLogicServer> <BEA-000360> <The server started in RUNNING mode.>?
⑤ 編寫(xiě)Dockerfile
[root@docker1 weblogic_jdk1.6]# docker ps -l
CONTAINER ID ? ? ? ?IMAGE ? ? ? ? ? ? ? COMMAND ? ? ? ? ? ? CREATED ? ? ? ? ? ? STATUS ? ? ? ? ? ? ?PORTS ? ? ? ? ? ? ? ? ? NAMES
26bbe0516fda ? ? ? ?sshd:centos ? ? ? ? "/run.sh" ? ? ? ? ? 25 hours ago ? ? ? ?Up About an hour ? ?0.0.0.0:32768->22/tcp ? fervent_liskov
[root@docker1 weblogic_jdk1.6]# docker commit 26bbe0516fda weblogic_1
sha256:ecb34d15c0e5ac648b63806c1db031e508330c39380827bdfdf76c0cfb01e47e
[root@docker1 weblogic_jdk1.6]# docker images
REPOSITORY ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TAG ? ? ? ? ? ? ? ? IMAGE ID ? ? ? ? ? ?CREATED ? ? ? ? ? ? SIZE
weblogic_1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? latest ? ? ? ? ? ? ?ecb34d15c0e5 ? ? ? ?16 seconds ago ? ? ?932.4 MB
編寫(xiě)Dockerfile,內(nèi)容為:
[root@docker1 weblogic_jdk1.6]# vim Dockerfile
FROM weblogic_1
#設(shè)置繼承自我們創(chuàng)建的weblogic_1鏡像
MAINTAINER waitfish from dockerpool.com
#下面是一些創(chuàng)建者的基本信息
#設(shè)置環(huán)境變量,所有操作都是非交互的
ENV DEBIAN_FRONTEND noninteractive
RUN echo "Asia/Shanghai" > /etc/timezone
#注意這里要更改系統(tǒng)的時(shí)區(qū)設(shè)置,因?yàn)樵赪eb應(yīng)用中經(jīng)常會(huì)用到時(shí)區(qū)這個(gè)系統(tǒng)變量,默認(rèn)的Centos會(huì)讓你的應(yīng)用程序發(fā)生不可思議的效果
COPY jdk1.6.0_45 /jdk
COPY run.sh /run.sh
RUN chmod +x /run.sh
EXPOSE 7001
CMD ["/run.sh"]
⑥ 編寫(xiě)自啟動(dòng)腳本
[root@docker1 weblogic_jdk1.6]# vim run.sh
#!/bin/bash
/usr/sbin/sshd -D &
/opt/Middleware/user_projects/domains/base_domain/startWebLogic.sh
⑦ 創(chuàng)建鏡像及測(cè)試
[root@docker1 weblogic_jdk1.6]# docker commit aca388afeddf weblogic_1 ? ? ? #提交為系統(tǒng)鏡像
sha256:2e2c8f451d6f67fcef7bee131b5ae2d6f7a7b20cb4856cb467e60c274cad72b5
[root@docker1 weblogic_jdk1.6]# docker images
REPOSITORY ? ? ? ? ? ? TAG ? ? ? ? ? ? ? ? IMAGE ID ? ? ? ? ? ?CREATED ? ? ? ? ? ? SIZE
weblogic_1 ? ? ? ? ? ? latest ? ? ? ? ? ? ?2e2c8f451d6f ? ? ? ?15 seconds ago ? ? ?916.8 MB
......
[root@docker1 weblogic_jdk1.6]# docker build -t weblogic:jdk1.6 . ? ? ? ? #創(chuàng)建鏡像
Sending build context to Docker daemon 1.328 GB
Step 1 : FROM weblogic_1
?---> 2e2c8f451d6f
Step 2 : MAINTAINER waitfish from dockerpool.com
?---> Running in 27fb2dea4049
?---> c79723b5eb5e
Removing intermediate container 27fb2dea4049
Step 3 : ENV DEBIAN_FRONTEND noninteractive
?---> Running in 14daeedfeaa1
?---> 5faf1cbfb17a
Removing intermediate container 14daeedfeaa1
Step 4 : RUN echo "Asia/Shanghai" > /etc/timezone
?---> Running in b5e5609ad99e
?---> ad3ec21e63c0
Removing intermediate container b5e5609ad99e
Step 5 : COPY jdk1.6.0_45 /jdk
?---> 1c5784f367bd
Removing intermediate container b28a7a58bd5f
Step 6 : COPY run.sh /run.sh
?---> 91981814ac53
Removing intermediate container 4ef6cfdaa406
Step 7 : RUN chmod +x /run.sh
?---> Running in a7eb291a4d0b
?---> ea480cdc54ba
Removing intermediate container a7eb291a4d0b
Step 8 : EXPOSE 7001
?---> Running in df437c71d728
?---> 4560124e1eaf
Removing intermediate container df437c71d728
Step 9 : CMD /run.sh
?---> Running in e1727a8d8da5
?---> 1fdf1970afad
Removing intermediate container e1727a8d8da5
Successfully built 1fdf1970afad
[root@docker1 weblogic_jdk1.6]# ^C
[root@docker1 weblogic_jdk1.6]#?
[root@docker1 weblogic_jdk1.6]# docker run -d -P weblogic:jdk ? ? ? ? ?#啟動(dòng)
Unable to find image 'weblogic:jdk' locally
Trying to pull repository docker.io/library/weblogic ...?
^C
[root@docker1 weblogic_jdk1.6]# docker images
REPOSITORY ? ? ? ? ? ? TAG ? ? ? ? ? ? ? ? IMAGE ID ? ? ? ? ? ?CREATED ? ? ? ? ? ? SIZE
weblogic ? ? ? ? ? ? ? jdk1.6 ? ? ? ? ? ? ?1fdf1970afad ? ? ? ?2 minutes ago ? ? ? 1.125 GB
weblogic_1 ? ? ? ? ? ? latest ? ? ? ? ? ? ?2e2c8f451d6f ? ? ? ?4 minutes ago ? ? ? 916.8 MB
......
[root@docker1 weblogic_jdk1.6]# docker run -d -P weblogic:jdk1.6
dd43b6de6b33a74c373c24c5f089c95ea3312541b96b6942c8b07fec9738b337
[root@docker1 weblogic_jdk1.6]# docker ps
CONTAINER ID ? ? ? ?IMAGE ? ? ? ? ? ? ? COMMAND ? ? ? ? ? ? CREATED ? ? ? ? ? ? STATUS ? ? ? ? ? ? ?PORTS ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?NAMES
dd43b6de6b33 ? ? ? ?weblogic:jdk1.6 ? ? "/run.sh" ? ? ? ? ? 5 seconds ago ? ? ? Up 4 seconds ? ? ? ?0.0.0.0:32771->22/tcp, 0.0.0.0:32770->7001/tcp ? peaceful_saha
aca388afeddf ? ? ? ?sshd:centos ? ? ? ? "/run.sh" ? ? ? ? ? 22 hours ago ? ? ? ?Up 22 hours ? ? ? ? 0.0.0.0:32769->22/tcp ? ? ? ? ? ? ? ? ? ? ? ? ? ?grave_turing
使用瀏覽器登錄Weblogic控制臺(tái),如圖所示:
如果遇到如下界面:
輸入10.0.0.10:32770/console
輸入用戶名和密碼:weblogic ? weblogic_test
如果輸入:10.0.0.10:32770
見(jiàn)參考文章:https://blog.51cto.com/sf1314/2055910?
??
轉(zhuǎn)載于:https://blog.51cto.com/sf1314/2048625
總結(jié)
以上是生活随笔為你收集整理的【系列5】使用Dockerfile创建带weblogic的Centos Docker镜像的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: (3两个例子)从零开始的嵌入式图像图像处
- 下一篇: 通过简单的线性回归理解机器学习的基本原理