For Distributed operating systems

Switching a Liberty Docker server between run and debug mode by using developer tools

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.

Before you begin

You must create a Liberty Docker server by using WebSphere Developer Tools. For more information about using WebSphere Developers Tools to create a Liberty server in a Docker container, see Creating a workbench Liberty server in a Docker container by using developer tools.

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

  1. Switch your server from run mode to debug mode:
    1. Open the Servers view in WebSphere Developer Tools by clicking Window > Show view > Servers.
    2. Start your server in debug mode by right-clicking your_server and selecting Debug.
      The tools go through the following steps:
      1. Disconnect from the your_server container and stop the container.
      2. Commit the your_server container to a new image that is named your_server_debug_websphere-liberty
      3. Create a new container that is named your_server_debug from the your_server_debug_websphere-liberty image.
      4. Connect to the your_server_debug container.
    3. 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.

  2. 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:
    1. Disconnect from the your_server_debug container and stop the container.
    2. Commit the your_server_debug container to a new image that is named your_server_run_websphere-liberty
    3. Create a new container that is named your_server_run from the your_server_run_websphere-liberty image.
    4. Connect to the your_server_run container.
  3. Delete the your_server server by right-clicking your_server and selecting Delete.
  4. 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.