diff --git a/src/main/java/io/jenkins/docker/connector/DockerComputerSSHConnector.java b/src/main/java/io/jenkins/docker/connector/DockerComputerSSHConnector.java index 029d2bc2d..b816e3fc4 100644 --- a/src/main/java/io/jenkins/docker/connector/DockerComputerSSHConnector.java +++ b/src/main/java/io/jenkins/docker/connector/DockerComputerSSHConnector.java @@ -278,8 +278,10 @@ public void beforeContainerCreated(DockerAPI api, String workdir, CreateContaine } final Ports portBindings = hostConfig.getPortBindings(); if (portBindings != null) { - portBindings.add(sshPortBinding); - hostConfig.withPortBindings(portBindings); + if(portBindings.getBindings().get(sshPortBinding.getExposedPort()).length == 0) { + portBindings.add(sshPortBinding); + hostConfig.withPortBindings(portBindings); + } } else { hostConfig.withPortBindings(sshPortBinding); }