Yay! This is the moment we’ve been waiting for. We’ve created all of the images needed to run WebLogic now we’re ready to create a containerized domain with a running admin server.
Start the Admin Server
To start a containerized admin server run the following docker command:
1 |
$ docker run -d --name wlsadmin --hostname wlsadmin -p 8001:8001 1221-domain |
This docker run statement starts the container in the background using the 1221-domain image we created earlier. The -p 8001:8001 acts as a port forwarder, allowing us to access the admin server running on port 8001 inside the container over port 8001.
You can then use ‘docker attach’ or ‘docker logs’ to view the container’s stdout.
1 2 3 4 5 6 7 |
$ docker logs wlsadmin <Jan 17, 2017 6:31:31 PM UTC> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 172.17.0.2:8001 for protocols iiop, t3, ldap, snmp, http.> <Jan 17, 2017 6:31:31 PM UTC> <Notice> <Server> <BEA-002613> <Channel "Default[2]" is now listening on 127.0.0.1:8001 for protocols iiop, t3, ldap, snmp, http.> <Jan 17, 2017 6:31:31 PM UTC> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 0:0:0:0:0:0:0:1%lo:8001 for protocols iiop, t3, ldap, snmp, http.> <Jan 17, 2017 6:31:31 PM UTC> <Notice> <WebLogicServer> <BEA-000360> <The server started in RUNNING mode.> <Jan 17, 2017 6:31:32 PM UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING.> |
Once the admin server is running, you can then use your browser to connect to the container at http://localhost:8001/console
Create a Managed Server
Oracle has provided us with a helper script for creating a managed server. Keep in mind the Docker architecture for running WebLogic specifies that each WebLogic process runs in its own container. The admin server is running in its own container.
To launch a managed server we will create another instance of a container image using a script provided by Oracle.
1 2 |
$ cd docker-images/OracleWebLogic/samples/1221-domain/container-scripts $ docker run -d --link wlsadmin:wlsadmin 1221-domain createServer.sh |
Once that command returns, view the logs for the new container. You can see the output from the createServer.sh script – merely WLST for creating a managed server instance. Be sure to replace my container ID with your container ID.
Be sure to replace my container ID with your container ID.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
$ docker logs 61f03cae565f Initializing WebLogic Scripting Tool (WLST) ... Welcome to WebLogic Server Administration Scripting Shell Type help() for help on available commands Connecting to t3://wlsadmin:8001 with userid weblogic ... Successfully connected to Admin Server "AdminServer" that belongs to domain "base_domain". Warning: An insecure protocol was used to connect to the server. To ensure on-the-wire security, the SSL port or Admin port should be used instead. Location changed to edit tree. This is a writable tree with DomainMBean as the root. To make changes you will need to start an edit session via startEdit(). For more help, use help('edit'). Starting an edit session ... Started edit session, be sure to save and activate your changes once you are done. You have acquired an exclusive lock, which will cause a subsequent call to startEdit by the same owner to wait until this edit session lock is releasedSaving all your changes ... Saved all your changes successfully. Activating all your changes, this may take a while ... The edit lock associated with this edit session is released once the activation is completed. Activation completed |
The Docker command above will create another container linked to our ‘wlsadmin’ container and then execute the createServer.sh script. If you take a look at the contents of this script, it essentially runs two WLST scripts. One creates a WebLogic machine and the other creates a managed server.
Let’s see what Docker processes are running:
1 2 3 4 5 6 7 |
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2f86842925f6 1221-domain "createServer.sh" 33 seconds ago Up 32 seconds 5556/tcp, 7001/tcp, 8001/tcp, 8453/tcp drunk_albattani 7fdd44b9178c 1221-domain "startWebLogic.sh" 14 minutes ago Up 14 minutes 5556/tcp, 7001/tcp, 8453/tcp, 0.0.0.0:8001->8001/tcp wlsadmin |
You can see from this output that we have two Docker processes running. The bottom one show in my output is the admin server (noted by startWebLgoic.sh as the command), and the top one is the managed server we set out to create using the createServer.sh script.
Now let’s check out the admin console and verify our managed server is up and running.
Shutdown Everything Down
To shut down your running containers, Oracle has provided a helper script that will go through and remove all your running containers.
1 |
$ docker-images/OracleWebLogic/samples/rm_containers.sh |
Run docker ps to confirm that all the containers are shut down.
1 2 3 4 |
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES $ |
Wrapping Up
Over these 5 steps, I showed you how to create docker images for Oracle JRE and Oracle WebLogic using the dockerfiles from Oracle’s GitHub repo. I also launched an admin server and created a managed server using the samples from Oracle again.
The samples from Oracle serve as a great starting point for your organization. You should spend some time and snoop around their dockerfiles and samples. Customize them for your needs. In particular, I recommend checking out the multi-host docker image which can be used to deploy Weblogic across multiple machines – which is a more realistic operational scenario than the single-host scenario I presented in this article.