Skip to content

Conversation

@natefoo
Copy link
Member

@natefoo natefoo commented Sep 25, 2025

I have an environment where I need to restrict what host ports are selected when running GxITs. The Docker daemon offers no solution for this, when not specified ports are chosen from the range specified by the system-wide ip_local_port_range kernel parameter. This PR adds a docker_host_port_cmd which can be used to run something that returns a free port, e.g.:

#!/bin/bash

START=32768
END=32968

for port in $(seq $START $END); do
    if ! ss -ltn 2>/dev/null | awk '{print $4}' | grep -q ":$port\$"; then
        echo $port
        exit 0
    fi
done

echo "No free ports found in range $START-$END" >&2
exit 1

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. Enable GxITs and verify functionality
    2. Set docker_host_port_cmd to e.g. echo 11234
    3. Run a GxIT and verify host port is 11234

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

@jmchilton
Copy link
Member

I'm fine with this in theory - I'm anxious the failing tests might be related? They do appear to be docker and IT adjacent.

@natefoo
Copy link
Member Author

natefoo commented Sep 26, 2025

Pfft surely I am not the cause of docker: invalid containerPort: None7000 😅

@natefoo natefoo force-pushed the docker-host-port-cmd branch from a33c38a to e667761 Compare September 26, 2025 14:03
@mvdbeek mvdbeek merged commit 3e34992 into galaxyproject:dev Oct 1, 2025
59 of 66 checks passed
@github-actions
Copy link

github-actions bot commented Oct 1, 2025

This PR was merged without a "kind/" label, please correct.

@ahmedhamidawan ahmedhamidawan modified the milestones: 26.0, 25.1 Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants