|
11 | 11 | import com.github.dockerjava.api.command.ExecCreateCmd; |
12 | 12 | import com.github.dockerjava.api.command.ExecCreateCmdResponse; |
13 | 13 | import com.github.dockerjava.api.command.InspectContainerResponse; |
| 14 | +import com.github.dockerjava.api.command.VersionCmd; |
| 15 | +import com.github.dockerjava.api.model.Version; |
14 | 16 | import com.google.common.base.Joiner; |
15 | 17 | import edu.umd.cs.findbugs.annotations.CheckForNull; |
16 | 18 | import edu.umd.cs.findbugs.annotations.NonNull; |
@@ -298,25 +300,30 @@ public void launch(final SlaveComputer computer, TaskListener listener) |
298 | 300 | + Joiner.on(" ").join(resolvedEntryPointCmd)); |
299 | 301 |
|
300 | 302 | final String execId; |
| 303 | + final String actualApiVersion; |
301 | 304 | try (final DockerClient client = api.getClient()) { |
302 | | - final ExecCreateCmd cmd = client.execCreateCmd(containerId) |
| 305 | + final ExecCreateCmd execCmd = client.execCreateCmd(containerId) |
303 | 306 | .withAttachStdin(true) |
304 | 307 | .withAttachStdout(true) |
305 | 308 | .withAttachStderr(true) |
306 | 309 | .withTty(false) |
307 | 310 | .withCmd(resolvedEntryPointCmd); |
308 | 311 | if (StringUtils.isNotBlank(userOrNull)) { |
309 | | - cmd.withUser(userOrNull); |
| 312 | + execCmd.withUser(userOrNull); |
310 | 313 | } |
311 | | - final ExecCreateCmdResponse exec = cmd.exec(); |
312 | | - execId = exec.getId(); |
| 314 | + final ExecCreateCmdResponse execResponse = execCmd.exec(); |
| 315 | + execId = execResponse.getId(); |
| 316 | + |
| 317 | + final VersionCmd versionCmd = client.versionCmd(); |
| 318 | + final Version version = versionCmd.exec(); |
| 319 | + actualApiVersion = version.getApiVersion(); |
313 | 320 | } |
314 | 321 | final String js = "{ \"Detach\": false, \"Tty\": false }"; |
315 | 322 | final Socket socket = api.getSocket(); |
316 | 323 | final OutputStream out = socket.getOutputStream(); |
317 | 324 | final InputStream in = socket.getInputStream(); |
318 | 325 | final PrintWriter w = new PrintWriter(new OutputStreamWriter(out, StandardCharsets.US_ASCII)); |
319 | | - w.println("POST /v1.32/exec/" + execId + "/start HTTP/1.1"); |
| 326 | + w.println("POST /v" + actualApiVersion + "/exec/" + execId + "/start HTTP/1.1"); |
320 | 327 | w.println("Host: docker.sock"); |
321 | 328 | w.println("Content-Type: application/json"); |
322 | 329 | w.println("Upgrade: tcp"); |
|
0 commit comments