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

Need a mechanism (and API) to reliably determine if a JVM is executing in a container context

XMLWordPrintable

    • svc

      increasingly developers are using Java in the context of container runtimes such as Docker, podman and kubernetes.

      As containers are primarily resource managers which provide some level of resource control and isolation, such behavior(s) can impact the serviceability of a JVM executing in such a context.

      It would be (highly) desirable to be able to determine if a JVM r/t is (or is not) executing within the context of such a container/resource controller.

      Unfortunately there does not appear to be an existing platform API that can provide this information to the Java r/t, so some type of heuristic would need to be used, e.g:
      - filesystem of type 'overlay' mounted on '/'
      - introspection of pid 1 (init or systemd vs. some other arbitrary process)
      - existence of env var or file: /run/.containerenv for podman

            lcable Larry Cable
            lcable Larry Cable
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: