diff --git a/core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java b/core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java index 1efd20d2da382..19882135e0e29 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java @@ -6,6 +6,7 @@ import java.util.List; import io.quarkus.deployment.util.ContainerRuntimeUtil; +import io.quarkus.deployment.util.ContainerRuntimeUtil.ContainerRuntime; public class IsDockerWorking extends IsContainerRuntimeWorking { public IsDockerWorking() { @@ -19,7 +20,8 @@ public IsDockerWorking(boolean silent) { private static class DockerBinaryStrategy implements Strategy { @Override public Result get() { - if (ContainerRuntimeUtil.detectContainerRuntime(false) != UNAVAILABLE) { + if (ContainerRuntimeUtil.detectContainerRuntime(false, + ContainerRuntime.DOCKER, ContainerRuntime.PODMAN) != UNAVAILABLE) { return Result.AVAILABLE; } else { return Result.UNKNOWN; diff --git a/core/deployment/src/main/java/io/quarkus/deployment/IsPodmanWorking.java b/core/deployment/src/main/java/io/quarkus/deployment/IsPodmanWorking.java index 2a6fce41c656d..a9e5aa857f1d3 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/IsPodmanWorking.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/IsPodmanWorking.java @@ -5,6 +5,7 @@ import java.util.List; import io.quarkus.deployment.util.ContainerRuntimeUtil; +import io.quarkus.deployment.util.ContainerRuntimeUtil.ContainerRuntime; public class IsPodmanWorking extends IsContainerRuntimeWorking { public IsPodmanWorking() { @@ -21,7 +22,11 @@ public IsPodmanWorking(boolean silent) { private static class PodmanBinaryStrategy implements Strategy { @Override public Result get() { - return (ContainerRuntimeUtil.detectContainerRuntime(false) != UNAVAILABLE) ? Result.AVAILABLE : Result.UNKNOWN; + if (ContainerRuntimeUtil.detectContainerRuntime(false, ContainerRuntime.PODMAN) != UNAVAILABLE) { + return Result.AVAILABLE; + } else { + return Result.UNKNOWN; + } } } } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/util/ContainerRuntimeUtil.java b/core/deployment/src/main/java/io/quarkus/deployment/util/ContainerRuntimeUtil.java index 10d33810a02a0..97133d8b2a899 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/util/ContainerRuntimeUtil.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/util/ContainerRuntimeUtil.java @@ -6,6 +6,7 @@ import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; @@ -42,21 +43,20 @@ private ContainerRuntimeUtil() { * @return a fully resolved {@link ContainerRuntime} indicating if Docker or Podman is available and in rootless mode or not * @throws IllegalStateException if no container runtime was found to build the image */ - public static ContainerRuntime detectContainerRuntime() { - return detectContainerRuntime(true); - } - - public static ContainerRuntime detectContainerRuntime(List<ContainerRuntime> orderToCheckRuntimes) { + public static ContainerRuntime detectContainerRuntime(ContainerRuntime... orderToCheckRuntimes) { return detectContainerRuntime(true, orderToCheckRuntimes); } - public static ContainerRuntime detectContainerRuntime(boolean required) { - return detectContainerRuntime(required, List.of(ContainerRuntime.DOCKER, ContainerRuntime.PODMAN)); + public static ContainerRuntime detectContainerRuntime(boolean required, ContainerRuntime... orderToCheckRuntimes) { + return detectContainerRuntime( + required, + ((orderToCheckRuntimes != null) && (orderToCheckRuntimes.length > 0)) ? Arrays.asList(orderToCheckRuntimes) + : List.of(ContainerRuntime.DOCKER, ContainerRuntime.PODMAN)); } public static ContainerRuntime detectContainerRuntime(boolean required, List<ContainerRuntime> orderToCheckRuntimes) { ContainerRuntime containerRuntime = loadContainerRuntimeFromSystemProperty(); - if (containerRuntime != null) { + if ((containerRuntime != null) && orderToCheckRuntimes.contains(containerRuntime)) { return containerRuntime; } diff --git a/extensions/container-image/container-image-docker-common/deployment/src/main/java/io/quarkus/container/image/docker/common/deployment/CommonProcessor.java b/extensions/container-image/container-image-docker-common/deployment/src/main/java/io/quarkus/container/image/docker/common/deployment/CommonProcessor.java index ff9e2bbdbc5a7..113468914730e 100644 --- a/extensions/container-image/container-image-docker-common/deployment/src/main/java/io/quarkus/container/image/docker/common/deployment/CommonProcessor.java +++ b/extensions/container-image/container-image-docker-common/deployment/src/main/java/io/quarkus/container/image/docker/common/deployment/CommonProcessor.java @@ -259,7 +259,7 @@ protected RuntimeException containerRuntimeException(String executableName, Stri private String getExecutableName(C config, ContainerRuntime containerRuntime) { return config.executableName() - .orElseGet(() -> detectContainerRuntime(List.of(containerRuntime)).getExecutableName()); + .orElseGet(() -> detectContainerRuntime(containerRuntime).getExecutableName()); } private DockerfilePaths getDockerfilePaths(C config,