Update applications inside running Docker containers

You might encounter some situations where you need to directly update applications running inside the Docker containers. For example, we can test new classes, libraries, or debug issues on a local test, quality assurance, or authoring environment before you decide to make the changes in your production environment. This procedure explains how to copy files from your local Docker host into the running containers.

Note: If the environment is managed by Docker orchestration tools (such as Marathon), ensure that you follow the recommended guidelines of building new Docker images to deploy. Otherwise, your copied files will be lost after a restart due to the nature or orchestration tools. For more information about building new images, see Building custom Docker images based on customization packages.

If you still must copy files, note that sometimes replacing files requires you to restart the entire Docker container before our changes take effect. We can implement third party technical solutions to restart the JVM inside the container instead of restarting the container.


Task info

Assuming that you have a file (.war, .jar, .jsp, .js, .css) to load to your running container, use the following steps to copy the file to your destination.


Procedure

  1. Copy your file to the Docker container.

    Method Explanation
    By using 'docker cp' command

      docker cp <local_file> <container_name>:destination_path>

    For example, to update the Transaction container (named set_app_1) with myupdate.jar, use

      docker cp myupdate.jar setup_app_1:/opt/WebSphere/AppServer/profiles/default/installedApps/localhost/ts.ear/lib

    By using a Docker volume driver to mount the local file into the target Docker container For more information about volume drivers, see the Docker documentation, Use a volume driver.

  2. Restart.

    • For updates to Store and Search containers, restart the containers. For example,

        docker restart store, search

    • For Transaction server, we can restart the Transaction container or restart the Transaction EAR from the WebSphere Application Server Administrative console. To restart in the WebSphere Application Server Administrative Console:

      1. Log on to the WebSphere Application Server Administrative Console https://hostname:9043/ibm/console.

      2. Click Servers > Server Types > WebSphere application servers.

      3. Select server1 and click Restart.