For your Liberty Docker server,
you can use WebSphere Developer Tools to switch your server between run and debug mode. When you
switch between these modes, the tools create a Docker image and a Docker container, which you can
save.
About this task
When you create a Liberty server in a
Docker container, the run command and host mapped ports are fixed. As a result, when you switch a
Liberty Docker server between run and debug
modes, WebSphere Developer Tools commit a new Docker image based on your Docker container. This
action preserves all of your changes to the container at that point. Then, the tools create a new
container from the new image, but modify the run command to either run or debug the server. When you
switch to debug mode, the tools map the debug port to the host.
The tools do not delete the original image and container. However, the tools remove any temporary
images and containers when you switch modes. To avoid losing changes that you made to your server in
debug mode, you can save the last temporary image and container when you delete a Liberty Docker server.
Procedure
-
Switch your server from run mode to debug mode:
-
Open the Servers view in WebSphere Developer Tools by clicking .
-
Start your server in debug mode by right-clicking
your_server and selecting
Debug.
The tools go through the following steps:
- Disconnect from the your_server container and stop the
container.
- Commit the your_server container to a new image that is
named your_server_debug_websphere-liberty
- Create a new container that is named your_server_debug
from the your_server_debug_websphere-liberty image.
- Connect to the your_server_debug container.
-
If the tools display the Server Execution Mode Switch window, click
OK to continue.
The tools display the Server Execution Mode Switch window only the first
time that you switch the mode for your server.
-
Switch your server back to run mode from debug mode by right-clicking
your_server and selecting Run.
The tools go through the following steps:
- Disconnect from the your_server_debug container and stop
the container.
- Commit the your_server_debug container to a new image
that is named your_server_run_websphere-liberty
- Create a new container that is named your_server_run
from the your_server_run_websphere-liberty image.
- Connect to the your_server_run container.
-
Delete the your_server server by right-clicking
your_server and selecting
Delete.
-
Click Yes to save the
your_server_run container and the
your_server_run_websphere-liberty image.
Results
You switched your server from run mode to debug mode and back to run mode. When you switched
back to run mode, you saved any changes that you made to the container and image when you were in
debug mode.