0

I am learning Docker, and creating an image for Oracle WebLogic 12.2.1.4 server.

My image is ready, working fine. It contains

  • an admin server
  • two managed servers

When I run my image with docker run -d -p 7001:7001 --name WL oracle/weblogic-12.2.1.4.0:1.0 the admin server starts automatically because I added the following line at the end of my Dockerfile:

CMD /u01/oracle/user_projects/domains/$DOMAIN_NAME/startWebLogic.sh 

But I need to start managed servers manually. I need to login into the container and start them by hand:

  1. docker exec -it WL /bin/bash
  2. ./startManagedWebLogic.sh MANAGED_SERVER_1 http://localhost:7001 &
  3. ./startManagedWebLogic.sh MANAGED_SERVER_2 http://localhost:7001 &

This is not what I want. I want to start managed servers automatically after admin server is up and running.

I was thinking about to create a new bash script, copy it into the image and use it to boot up the admin and managed servers. Like this:

start-wls-domain.sh

#!/bin/bash /u01/oracle/user_projects/domains/$DOMAIN_NAME/startWebLogic.sh & # there are a more sophisticated way to check the status of the admin server but it is okay for test sleep 60 ./startManagedWebLogic.sh MANAGED_SERVER_1 http://localhost:7001 & ./startManagedWebLogic.sh MANAGED_SERVER_2 http://localhost:7001 & 

This script can be called from Dockerfile with CMD command.

But with this solution, I lost the ability to see the output on the default Docker log. The docker logs WL -f will display nothing. Another issue with this bash script solution is if this script finished the container will stop running. Do I need an infinite loop at the end of this script?

If possible I would like to have a solution without start-wls-domain.sh.

What is the best and easiest way to start Weblogic managed servers automatically within a Docker container?

2
  • 1
    As a general rule you want to run one process per container. That lets you see docker logs normally, and lets features like Docker's restart policy automatically take care of things when any single process fails. I don't know how you'd translate that principle to WebLogic, though. Commented Jan 23, 2020 at 10:22
  • If I follow this principle than I need to create another image that contains only the managed server and then I need to start two instances from this image in order to I will have 2 managed servers in the WebLogic domain. It makes sense. Commented Jan 23, 2020 at 12:24

1 Answer 1

2

I followed the suggestions and I run different servers in different containers. That way I was able to start properly the server.

I published the solution on Github, here.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.