Skip to content

Commit 79dae25

Browse files
committed
Make ContainerRuntime detection less brittle
In the case of unavailable, isDocker() was throwing a NPE. Related to #49465 (comment)
1 parent e2db84d commit 79dae25

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildLocalContainerRunner.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public NativeImageBuildLocalContainerRunner(NativeConfig nativeConfig) {
2727
}
2828

2929
public static List<String> getVolumeAccessArguments(ContainerRuntime containerRuntime) {
30+
if (containerRuntime.isUnavailable()) {
31+
return List.of();
32+
}
33+
3034
final List<String> result = new ArrayList<>();
3135
if (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC) {
3236
if (containerRuntime.isDocker() && containerRuntime.isRootless()) {

core/deployment/src/main/java/io/quarkus/deployment/util/ContainerRuntimeUtil.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public String getExecutableName() {
245245
}
246246

247247
public boolean isDocker() {
248-
return this.executableName.equals("docker");
248+
return this == DOCKER || this == DOCKER_ROOTLESS || this == WSL || this == WSL_ROOTLESS;
249249
}
250250

251251
public boolean isPodman() {
@@ -260,6 +260,10 @@ public boolean isRootless() {
260260
return rootless;
261261
}
262262

263+
public boolean isUnavailable() {
264+
return this == UNAVAILABLE;
265+
}
266+
263267
public static ContainerRuntime of(String value) {
264268
for (ContainerRuntime containerRuntime : values()) {
265269
if (containerRuntime.name().equalsIgnoreCase(value)) {

0 commit comments

Comments
 (0)