Skip to content

Commit 628aa3d

Browse files
authored
Fix Docker version extraction when prefixed with 'v' (on some systems / distributions) (opensearch-project#20670)
Signed-off-by: Andriy Redko <drreta@gmail.com>
1 parent 14749f7 commit 628aa3d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

buildSrc/src/main/java/org/opensearch/gradle/docker/DockerSupportService.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,23 @@ public DockerAvailability getDockerAvailability() {
116116
lastResult = runCommand(execOperations, dockerPath, "version", "--format", "{{.Server.Version}}");
117117

118118
if (lastResult.isSuccess()) {
119-
version = Version.fromString(lastResult.stdout.trim(), Version.Mode.RELAXED);
119+
// On some systems, Docker reports version prefixed with 'v', on some without,
120+
// for example:
121+
//
122+
// $ docker info
123+
// Client: Docker Engine - Community
124+
// Version: v29.1.2
125+
// Context: default
126+
// Debug Mode: false
127+
//
128+
// $ docker info
129+
// Client:
130+
// Version: 28.2.2
131+
// Context: default
132+
// Debug Mode: false
133+
//
134+
final String versionString = lastResult.stdout.trim().replaceAll("^v", "");
135+
version = Version.fromString(versionString, Version.Mode.RELAXED);
120136

121137
isVersionHighEnough = version.onOrAfter(MINIMUM_DOCKER_VERSION);
122138

0 commit comments

Comments
 (0)