Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8190739

Generating Docker containers by Java Packager

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Withdrawn
    • Fix Version/s: tbd
    • Component/s: deploy
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Minimal risk, because it's a new option, it won't affect existing ones.
    • Interface Kind:
      Java API, add/remove/modify command line option

      Description

      Summary

      Add a new mode to Java Packager that will generate a Docker container with a base OS image, a JDK, and optionally, a bundled application. This feature is intended to be easy to use: the user specifies a jar file or module as an input, and receives a Docker container as an output.

      Problem

      Due to increasing popularity of Docker containers, we propose to add a new mode to Java Packager for creating those containers. Java Packager will let us provide a nice level of control using JLink and JDeps to include only the necessary modules from the JDK, and potentially the application code. The Dockerfile created by Java Packager can be used to customize the Docker base image and other aspects of the container.

      Solution

      The Java Packager will perform the following four steps to generate a Docker container from a user application and JDK:

      1. Prepare parameters for JLink. For modular applications, this is done by using the dependencies in the module-info.java file of the application. For non-modular applications in a .jar file we need to calculate the dependencies using JDeps.
      2. Generate a custom runtime image using JLink and the specified parameters.
      3. Create a Dockerfile that contains instructions for copying the generated Java runtime image, application files (optional), and other necessary actions in order to configure the base image.
      4. Generate a Docker container using the created Dockerfile, auto-downloaded Linux base image, and other required files.

      Specification

      New arguments for generating Docker containers:

      -docker-container

      New mode for generating Docker containers.

      -base-image

      Parameter for specifying Docker base image. Value is one of the following list: "ubuntu", "fedora", "debian", "centos", "oraclelinux". If not specified, we can consider using "ubuntu" by default.

      -container-jdk-home

      Parameter for specifying JDK home in case javapackager is run on Windows or Mac OS. We might consider naming this "-target-jdk-home" or just "-jdk-home". If not specified, we can auto-download the latest Linux JDK from web, generate the app image, and remove downloaded JDK from the container.

      -docker-file

      Parameter for specifying the Dockerfile in case the user needs to perform additional configuration for the base image. If this option is used, we will only add the entrypoint to the provided Dockerfile.

      Additionally, the user will be able to specify existing javapackager arguments, such as name, description, copyright, JVM args, etc.

      JDK for generating custom runtime image

      If user operates a Linux system, we can just use the current JDK, although -container-jdk-home will take precedence if specified. On non-Linux systems, we will use the JDK specified in "-container-jdk-home" and generate an interim Docker image for creating the final runtime image, or we will auto-download latest linux JDK from web if "-container-jdk-home" is not specified.

      Docker container without user application files

      If adding a user application is not required, the user will need to specify appropriate parameters for the existing options: "add-modules" (list of modules to add to jimage creation) and "strip-native-commands" (removes native executables from the jimage creation) to configure the Docker container appropriately.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kcr Kevin Rushforth
                Reporter:
                vdrozdov Victor Drozdov (Inactive)
                Reviewed By:
                Alexander Matveev, Andy Herrick
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: