Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/galaxy/config/sample/job_conf.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ execution:
# Following command can be used to tweak docker command.
#docker_cmd: /usr/local/custom_docker/docker

# Docker containers that expose ports (e.g. Interactive Tools) can
# optionally use a command to determine the host port that is exposed. By
# default, one is chosen at random (docker run -p <guest_port> ...).
#docker_host_port_cmd:

# Following can be used to connect to docker server in different
# ways (translated as -H argument to docker client).
#docker_host: unix:///var/run/docker.sock
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/tool_util/deps/container_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ def containerize_command(self, command: str) -> str:
set_user=self.prop("set_user", docker_util.DEFAULT_SET_USER),
run_extra_arguments=self.prop("run_extra_arguments", docker_util.DEFAULT_RUN_EXTRA_ARGUMENTS),
guest_ports=self.tool_info.guest_ports,
host_port_cmd=self.prop("host_port_cmd", None),
container_name=self.container_name,
**docker_host_props,
)
Expand Down
7 changes: 6 additions & 1 deletion lib/galaxy/tool_util/deps/docker_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def build_docker_run_command(
set_user: Optional[str] = DEFAULT_SET_USER,
host: Optional[str] = DEFAULT_HOST,
guest_ports: Union[bool, str, List[str]] = False,
host_port_cmd: Optional[str] = None,
container_name: Optional[str] = None,
) -> str:
env_directives = env_directives or []
Expand All @@ -129,10 +130,14 @@ def build_docker_run_command(
# When is True, expose all ports
command_parts.append("-P")
elif guest_ports:
if host_port_cmd:
host_port_cmd = f"$({host_port_cmd}):"
else:
host_port_cmd = ""
if not isinstance(guest_ports, list):
guest_ports = [guest_ports]
for guest_port in guest_ports:
command_parts.extend(["-p", guest_port])
command_parts.extend(["-p", f"{host_port_cmd}{guest_port}"])
if container_name:
command_parts.extend(["--name", container_name])
for volume in volumes:
Expand Down
Loading