add a fallback for docker detection on Mac (#6356)

Signed-off-by: garyschulte <garyschulte@gmail.com>
This commit is contained in:
garyschulte
2024-01-11 09:01:01 -08:00
committed by GitHub
parent f721c1c2c2
commit 945a44c598

View File

@@ -33,6 +33,8 @@ public class DockerDetector implements NatMethodDetector {
return stream
.filter(line -> line.contains("/docker"))
.findFirst()
// fallback to looking for /.dockerenv in case we are running on Docker for Mac
.or(() -> Optional.ofNullable(Files.exists(Paths.get("/.dockerenv")) ? "docker" : null))
.map(__ -> NatMethod.DOCKER);
} catch (IOException e) {
return Optional.empty();