Skip to content

Commit

Permalink
Port Bindings is not respected for SSH port
Browse files Browse the repository at this point in the history
1- Dashboard > Manage Jenkins > Configure Clouds
2- Add a new Cloud
3- Connect method SSH
4- Container settings
5- Port Bindings
     0.0.0.0:20000-20100:22
Expected Results
All docker-proxy process should use a port between 20000 and 20100

Tested for a year now with this fix and docker-proxy always gets a port in the specified range.
  • Loading branch information
ericlapier committed Jan 23, 2024
1 parent 20f21b3 commit a314e01
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit a314e01

Please sign in to comment.