skip to Main Content

Docker container automatically stops if I stop the server using the stopServer.sh script. What is recommended practice to restart the server?

I need to apply a new configuration and docker restart image_id remove the new configuration.

2

Answers


  1. What is recommended practice to restart the server?

    Stop the existing container with docker stop, delete it with docker rm, then docker run a new container with the same options. Using a higher-level tool like Docker Compose or Kubernetes will let you store the container options in a YAML file, which will make it easier to do this reproducibly.

    I need to apply a new configuration…the configuration in server.xml

    Get a copy of the default server.xml on your host system, maybe using docker cp to get it out of the existing container. Edit it locally. When you re-launch the container, use a Docker bind mount to inject the file into the container, like

    docker run ... -v "$PWD/server.xml":/etc/websphere/server.xml ...
    

    Do not use docker exec to try to administer the server, edit its configuration, restart it, etc. Any changes you make this way will be lost as soon as the container exits, and there are circumstances that can cause it to exit outside of your direct control.

    Login or Signup to reply.
  2. Recommended practice is to use jython script to make any necessary configuration when the container starts. Checkout this page ci.docker.websphere-traditional which describes all possible options, like preparing jython script or property files.

    So for example your dockerfile looks like:

    FROM ibmcom/websphere-traditional:<version>
    # copy property files and jython scripts, using the flag `--chown=was:root` to set the appropriate permission
    RUN /work/configure.sh
    

    And here is example from that page which is showing property file based config:

    For example, if you had the following /work/config/001-was-config.props:

    ResourceType=JavaVirtualMachine
    ImplementingResourceType=Server
    ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:JavaProcessDef=:JavaVirtualMachine=
    AttributeInfo=jvmEntries
    #
    #
    #Properties
    #
    initialHeapSize=2048 #integer,default(0)
    

    You can then create a new image which has this configuration by simply building the following Dockerfile:

    FROM ibmcom/websphere-traditional:latest
    COPY --chown=was:root 001-was-config.props /work/config/
    RUN /work/configure.sh
    

    You may use numeric prefixes on your prop file names, so props that have dependencies can be applied in an adequate order.

    It also describes best practices(quoting):

    According to Docker’s best practices you should create a new image
    (FROM ibmcom/websphere-traditional) which adds a single application
    and the corresponding configuration. You should avoid configuring the
    image manually (after it started) via Admin Console or wsadmin (unless
    it is for debugging purposes) because such changes won’t be present if
    you spawn a new container from the image.

    WebSphere traditional, not like Liberty, is using very complex configuration file structure and making manual changes to these files is not recommended.

    Restarting modified container could be a temporary solution, in your local env, but it cannot be considered as recommended deployment practice.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search