From 6776b59f893dc355fe0712d4d2d701e3c9a24e52 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Thu, 30 Jul 2020 18:10:28 +0300 Subject: [PATCH] NativeImageBuild: Add --user flag to podman --- .../pkg/steps/NativeImageBuildStep.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java index 4d5779363bde4..ab016b09f8bfb 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java @@ -101,15 +101,14 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa outputPath + ":" + CONTAINER_BUILD_VOLUME_PATH + ":z", "--env", "LANG=C"); if (SystemUtils.IS_OS_LINUX) { - if ("docker".equals(containerRuntime)) { - String uid = getLinuxID("-ur"); - String gid = getLinuxID("-gr"); - if (uid != null && gid != null && !"".equals(uid) && !"".equals(gid)) { - Collections.addAll(nativeImage, "--user", uid + ":" + gid); + String uid = getLinuxID("-ur"); + String gid = getLinuxID("-gr"); + if (uid != null && gid != null && !"".equals(uid) && !"".equals(gid)) { + Collections.addAll(nativeImage, "--user", uid + ":" + gid); + if ("podman".equals(containerRuntime)) { + // Needed to avoid AccessDeniedExceptions + nativeImage.add("--userns=keep-id"); } - } else if ("podman".equals(containerRuntime)) { - // Needed to avoid AccessDeniedExceptions - nativeImage.add("--userns=keep-id"); } } nativeConfig.containerRuntimeOptions.ifPresent(nativeImage::addAll);