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.
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
Stop the existing container with
docker stop
, delete it withdocker rm
, thendocker 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.Get a copy of the default
server.xml
on your host system, maybe usingdocker 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, likeDo 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.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:
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:
You can then create a new image which has this configuration by simply building the following Dockerfile:
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):
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.