Automate WebLogic in Docker Containers with a Shell Script
GIT Repository "LINK"
1. Setting Up the domain.properties
File
The script first checks if a domain.properties
file exists at the specified location. This file contains important credentials (admin-username
and admin-password
) for WebLogic, which are required for WebLogic's management console.
The script ensures that the file exists, and if not, creates it with default credentials. Then, it sets the appropriate file permissions (664), ensuring that the owner and group can read and write to the file.
2. Removing Any Existing Containers
Before launching a new WebLogic container, the script checks if any containers named weblogic-container
already exist. If so, it stops and removes them to avoid conflicts.
This ensures that a fresh WebLogic container is always started.
3. Launching a New WebLogic Docker Container
The script uses Docker to launch a new container based on the container-registry.oracle.com/middleware/weblogic:12.2.1.4
image. It maps ports, mounts the domain.properties
file, and runs the container in the background.
This command starts the WebLogic container with the necessary configurations, making it accessible on ports 7001
, 7004
, and 5556
.
4. Installing Required Packages
Inside the container, the script installs essential packages (procps
and net-tools
) that are required for process management and networking.
These tools help monitor and manage processes within the container.
5. Modifying config.xml
to Disable Administration Port
The script then modifies the WebLogic config.xml
to disable the administration port. This is done by searching for the <administration-port-enabled>
tag and changing its value to false
.
This ensures that WebLogic's administration port is not exposed.
6. Creating Log Directories for NodeManager and AdminServer
The script creates a logs
directory inside the WebLogic domain directory if it doesn't already exist. This directory is used to store log files for NodeManager and AdminServer.
This ensures that logs are properly stored and managed within the container.
7. Starting NodeManager
The script starts the NodeManager process, which is used for managing WebLogic Server instances remotely.
NodeManager is started in the background, and its output is redirected to a log file.
8. Stopping the AdminServer
Before restarting the AdminServer, the script stops it by killing its process. This is achieved by identifying the WebLogic server process and terminating it.
The ps aux
command lists all running processes, and kill -9
terminates the AdminServer process.
9. Restarting the AdminServer
After stopping the AdminServer, the script restarts it using the startWebLogic.sh
script.
The AdminServer is started in the background, and its output is directed to a log file for monitoring.
10. Checking the Status of the WebLogic Container
The script checks the status of the WebLogic Docker container to ensure it is running correctly.
It then lists all running processes inside the container to confirm that the AdminServer and NodeManager are functioning.
11. Completion
Finally, the script prints a completion message to indicate that all tasks have been completed successfully.
Complete Script:
#####################################
Join the conversation