Weblogic是一个基于Java EE架构的中间件(应用服务器),WebLogic由Oracle公司维护。

   WebLogic是用于开发、集成、部署和管理大型分布式Web应用、网络应用和数据库应用的Java应用服务器。是商业市场上最主要的Java (J2EE)应用服务器软件之一,也是世界上第一个成功商业化的J2EE应用服务器。
   与Tomcat不同的是,Weblogic是一个商业软件,所以需要有授权才能使用。不过,Oracle公司允许开发者在开发模式下使用Weblogic。如果开发者需要在生产环境中使用Weblogic,则需要购买Oracle公司的正规商业授权。Weblogic的安装软件可以到Oracle的官方网站下载。
   
   Weblogic的基本概念:
   ◆ Weblogic域:
   weblogic域是作为单元进行管理的一组相关的WebLog服务器资源。一个域包含一个或多个WebLogic服务器实例,这些实例可以是群集实例、非群集实例,或者群集与非群集实例的组合。一个域可以包含多个群集。域还包含部署在域中的应用程序组件、此域中的这些应用程序组件和服务器实例所需的资源和服务。应用程序和服务器实例使用的资源和服务示例包括计算机定义、可选网络通道、连接器和启动类。  
   ◆ Administration服务器
   域中包含一个特殊的WebLogic服务器实例,叫做Administration服务器,这是用户配置、管理域中所有资源的核心。
   ◆ Manager服务器
   通常,称加入Domain的其他实例为Managed服务器,所有的Web应用、EJB、Web服务和其他资源都部署在这些服务器上。
    一个典型的Weblogic部署应该如图11-4所示。
   如果要使用常规的administrator +node的方式部署,就需要在run.sh脚本中分别写出administrator服务器和node服务器的启动脚本。这样做的优点是:可以使用Weblogic的集群、同步等概念。部署一个集群应用程序,只需要安装一次应用到集群上即可。
    缺点是:
    Docker配置复杂了。
   没办法自动扩展集群的计算容量,如需添加节点,需要在administrator上先创建节点,然后再配置新的容器run.sh启动脚本,然后再启动容器。
   file://C:\Users\Sheng\AppData\Local\Temp\ct_tmp/1.png
   推荐将应用程序安装在adminiserver上面,当需要扩展时候,启动多个adminiserver节点即可,将adminiserver当作Managed server使用。这样做的优点和缺点和传统的部署方法恰恰相反。
   
   使用docker commit + Dockerfile方式创建镜像
   下面将以weblogic 12.11、jdk 1.6、centos7.4为例子,创建一个带有Weblogic服务的镜像。

① 准备工作
    由于Weblogic的安装、部署部署较为复杂,笔者将先通过docker run -ti进入容器完成大部分操作,然后通过docker commit将这个容器提交为一个镜像,最后再进一步使用Dcokerfile来完成最终的Weblogic镜像创建,对于一些复杂镜像的创建。
    在本地主机上创建weblogic目录,从其他主机上传jdk和weblogic安装文件到该目录下,并创建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参数运行之前创建的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

 在宿主主机查看容器的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

在这里使用命令行模式,在容器内进行weblogic的安装:
以console模式启动weblogic安装,默认使用图形界面安装:

[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]>                                                               #直接回车
   不使用默认的安装位置,我们将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]>                 #直接回车
因为我们这里使用的授权时开发模式的,所以选择不接收安全更新:

<-------------------- 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                                                                         #选择不接受更新升级

<-------------------- 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]>             #在这里选择默认的组件:

<-------------------- 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]>     
因为我们是在jdk目录下使用Java,所以weblogic记住了我们的jdk位置,选择使用默认的jdk位置,后面还需要选择产品安装目录,之后即开始安装过程。

<-------------------- 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服务。

③ 创建节点:
接下来,将创建默认的weblogic域和Adminserver节点:
同样使用console模式启动安装,并选择新建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]> 

选择默认的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]> 
设置新建的域名:

<------------------- Fusion Middleware Configuration Wizard ------------------>

Edit Domain Information:
------------------------

    |  Name  |    Value    |
   _|________|_____________|
   1| *Name: | base_domain |

Enter value for "Name" OR [Exit][Previous][Next]> 
使用默认的安装位置:

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

设置用户名和密码:
<------------------- 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]> 
根据授权,使用开发模式或生产模式:

<------------------- 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      #选择开发模式

<------------------- 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]> 
选择只安装一个administration server,其他服务的安装跟这个一样:

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

选择默认的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]> 
设置新建的域名:

<------------------- Fusion Middleware Configuration Wizard ------------------>

Edit Domain Information:
------------------------

    |  Name  |    Value    |
   _|________|_____________|
   1| *Name: | base_domain |

Enter value for "Name" OR [Exit][Previous][Next]> 
使用默认的安装位置:

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

设置用户名和密码:
<------------------- 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]> 
根据授权,使用开发模式或生产模式:

<------------------- 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]> 
选择只安装一个administration server,其他服务的安装跟这个一样:

<------------------- 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的一些环境变量:
[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
   使用用户名和密码启动一次Weblogic之后,会在/opy/Middleware/user_projects/domains/base_domain下面生产一个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

   创建security/boot.properties文件,内容如下:
   username=weblogic
   password=weblogic_test
   这样,再次启动Weblogic时,就不需要输入密码了。通过console的输出可以看到Weblogic在容器内启动成功,并监听到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.> 


⑤ 编写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

编写Dockerfile,内容为:
[root@docker1 weblogic_jdk1.6]# vim Dockerfile
FROM weblogic_1
#设置继承自我们创建的weblogic_1镜像
MAINTAINER waitfish from dockerpool.com

#下面是一些创建者的基本信息

#设置环境变量,所有操作都是非交互的
ENV DEBIAN_FRONTEND noninteractive

RUN echo "Asia/Shanghai" > /etc/timezone
#注意这里要更改系统的时区设置,因为在Web应用中经常会用到时区这个系统变量,默认的Centos会让你的应用程序发生不可思议的效果

COPY jdk1.6.0_45 /jdk
COPY run.sh /run.sh

RUN chmod +x /run.sh

EXPOSE 7001

CMD ["/run.sh"]

⑥ 编写自启动脚本
[root@docker1 weblogic_jdk1.6]# vim run.sh
#!/bin/bash
/usr/sbin/sshd -D &
/opt/Middleware/user_projects/domains/base_domain/startWebLogic.sh


⑦ 创建镜像及测试

[root@docker1 weblogic_jdk1.6]# docker commit aca388afeddf weblogic_1       #提交为系统镜像

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 .         #创建镜像

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          #启动

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控制台,如图所示:



如果遇到如下界面:


输入10.0.0.10:32770/console

blob.png


输入用户名和密码:weblogic   weblogic_test

blob.png


如果输入:10.0.0.10:32770

QQ截图20171229163218.png

见参考文章:https://blog.51cto.com/sf1314/2055910