Deploying Oracle WebLogic Server to Docker
Deploying Oracle WebLogic Server to Docker can streamline the process of running and managing WebLogic instances. In this blog post, we'll walk through the steps to deploy Oracle WebLogic to Docker and configure it for use in your applications.
Pre-requisites
Before you get started, ensure the following:
- Docker installed on your EC2 instance or local machine.
- Access to Oracle WebLogic Docker image, either from Oracle Container Registry or your private registry.
- A WebLogic Server Domain Configuration (like
config.xml
,domain.properties
, etc.) is required.
Step 1: Pull WebLogic Docker Image
To start, we need to pull the WebLogic Docker image. Oracle provides an official image for WebLogic on their container registry.
Login to below oracle container registry and select the version which you wanna deploy in our blog I have chosen to go with "12.2.1.4"
This command will download WebLogic 12.2.1.4 Docker image.
Step 2: Run the WebLogic Docker Container
Once the image is downloaded, we can run the WebLogic Docker container. Here’s how you can run the container with port mappings:
docker run --privileged -d -v /sys/fs/cgroup:/sys/fs/cgroup:ro centos/systemd
why use above command?
This mount is typically used when:
- You need to run a container with systemd as the init system, where systemd needs access to cgroup information to manage services.
- You need the container to understand and interact with resource limits and management settings on the host, but without allowing it to alter those settings.
To find out the type of network used in the container:
docker inspect -f '{{.HostConfig.NetworkMode}}' “container id”
ubuntu@ip-172-31-22-5:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bc8f2cd45854 77cc9e1b3043 "/u01/oracle/createA…" About an hour ago Up 33 minutes (unhealthy) 0.0.0.0:7001->7001/tcp, :::7001->7001/tcp, 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp serene_payne
we need to create a domain.properties file in our cloud VM for which we will be passing the WebLogic admin credentials in this file and mount it while running the conatiner.
Explanation of the Docker Command:
-d
: Runs the container in detached mode (in the background).-p 7001:7001
: Maps port 7001 (WebLogic Admin port) on the host to port 7001 in the container.-v $(pwd)/domain.properties:/u01/oracle/properties/domain.properties
: Mounts thedomain.properties
file from your local machine to the container.
Step 3: Verify the Running Docker Container
Once the container is running, you can verify it by listing the running Docker containers with the following command:
You should see your WebLogic container listed, including its container ID and the mapped ports.
Step 4: Access WebLogic Console
Now that the container is running, you can access the WebLogic console via the web browser.
For HTTP:
For HTTPS (SSL-enabled):
Replace <EC2_PUBLIC_IP>
with the public IP of your EC2 instance or the host running Docker.
Step 5: Disable Admin Server Port (Only if admin server port enabled is set to true)
By default, WebLogic may have the administration port enabled, which could expose the WebLogic Admin Console publicly. If you want to secure it and prevent the exposure of the admin port, follow these steps to disable it.
Step 5.1: Access the WebLogic Domain Configuration File
WebLogic’s domain configuration file, config.xml, is located at:
/u01/oracle/user_projects/domains/base_domain/config/config.xml
We can access the config file by using below command
ubuntu@ip-172-31-22-5:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bc8f2cd45854 77cc9e1b3043 "/u01/oracle/createA…" About an hour ago Up 33 minutes (unhealthy) 0.0.0.0:7001->7001/tcp, :::7001->7001/tcp, 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp serene_payne
ubuntu@ip-172-31-22-5:~$ docker exec -it bc8f2cd45854 /bin/bash
[oracle@bc8f2cd45854 oracle]$ cd user_projects/domains/base_domain/config/
[
[oracle@bc8f2cd45854 config]$ ls -lart
total 44
drwxr-x--- 2 oracle root 4096 Jan 9 05:26 startup
drwxr-x--- 2 oracle root 4096 Jan 9 05:26 security
drwxr-x--- 2 oracle root 4096 Jan 9 05:26 diagnostics
drwxr-x--- 2 oracle root 4096 Jan 9 05:26 jdbc
drwxr-x--- 2 oracle root 4096 Jan 9 05:26 deployments
drwxr-x--- 2 oracle root 4096 Jan 9 05:26 nodemanager
drwxr-x--- 2 oracle root 4096 Jan 9 05:26 configCache
drwxr-x--- 14 oracle root 4096 Jan 9 05:26 ..
-rw-r----- 1 oracle root 3724 Jan 9 05:48 config.xml_bkp
-rw-r----- 1 oracle root 3725 Jan 9 06:14 config.xml
drwxr-x--- 9 oracle root 4096 Jan 9 06:17 .
[oracle@bc8f2cd45854 config]$ pwd
/u01/oracle/user_projects/domains/base_domain/config
Always make sure you take any backup of configuration changes.
Step 5.2: Disable Admin Server Port
To disable the admin server port (if it’s enabled), we’ll need to modify the config.xml
file. You can do this using the sed
command to change the <administration-port-enabled>
value from true
to false
.
Here’s the sed
command to do that:
What does this command do?
sed -i
: Edit the file in place (without creating a backup).s/<administration-port-enabled>true<\/administration-port-enabled>/<administration-port-enabled>false<\/administration-port-enabled>/
: Replacestrue
withfalse
in the<administration-port-enabled>
tag, disabling the admin server port.
Step 6: Restart the WebLogic Server
Once you’ve disabled the admin server port, restart the WebLogic container for the changes to take effect:
Replace <container_id>
with the ID of your running WebLogic Docker container.
Step 7: Verify the Changes
Finally, you can verify the changes by accessing the WebLogic Admin Console again via your browser. The admin server port should now be disabled, and you should no longer be able to access it through the public network.
Additional Considerations:
Firewall Configuration: Ensure that necessary ports (e.g., 7001, 7002) are open in your EC2 instance’s security group, or any firewall settings you may have.
WebLogic Logs: If you encounter any issues, you can check the logs within the Docker container by running:
- WebLogic Version Compatibility: Always ensure that the version of WebLogic you're using is compatible with Docker. Additionally, testing on a staging environment is recommended before deploying to production.
Join the conversation