Search code examples
javadockercontainersnessus

How to update Java inside Container


I am fairly new to running Docker and have a question about updating java. Do I need to completely rebuild the container if we need to update the java version? Our nessus scans are flagging the java version by scanning the docker/overlay2 folder on the host.

Thanks!!

I have not tried anything yet, too afraid to destroy the server.


Solution

  • There are severals ways. The chosen way may depend on what you want to get in the final result.

    1. Change the base image to use needed java version and build your new image with updated java version. You can find java images there https://hub.docker.com/_/openjdk/tags

    2. Change your Docker file, add commands to install/upgrade java version. Then build your new image

    3. Upgrade java version inside your container, and then use docker commit to save your changes to the new image https://docs.docker.com/engine/reference/commandline/commit/