Class ContainerUtil
- java.lang.Object
-
- org.apache.logging.log4j.kubernetes.ContainerUtil
-
public class ContainerUtil extends Object
Locate the current docker container.
-
-
Constructor Summary
Constructors Constructor Description ContainerUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getContainerId()
Returns the container id when running in a Docker container.
-
-
-
Constructor Detail
-
ContainerUtil
public ContainerUtil()
-
-
Method Detail
-
getContainerId
public static String getContainerId()
Returns the container id when running in a Docker container. This inspects /proc/self/cgroup looking for a Kubernetes Control Group. Once it finds one it attempts to isolate just the docker container id. There doesn't appear to be a standard way to do this, but it seems to be the only way to determine what the current container is in a multi-container pod. It would have been much nicer if Kubernetes would just put the container id in a standard environment variable.- See Also:
- Stackoverflow for a discussion on retrieving the containerId.,
Copyright © 1999-1969 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.
-
-