diff --git a/config/plugins/interactive_environments/jupyter/config/jupyter.ini.sample b/config/plugins/interactive_environments/jupyter/config/jupyter.ini.sample index ec7cedbeddf..ad73a20bb85 100644 --- a/config/plugins/interactive_environments/jupyter/config/jupyter.ini.sample +++ b/config/plugins/interactive_environments/jupyter/config/jupyter.ini.sample @@ -40,3 +40,7 @@ command_inject = --sig-proxy=true -e DEBUG=false -e DEFAULT_CONTAINER_RUNTIME=12 # share data between the IE and Galaxy. #docker_galaxy_temp_dir = None +# If your Docker container exposes more then one port, Galaxy needs to know to +# which ports it needs to connect. With this option you can specify the port number +# inside your container to which Galaxy should connect the UI. +# docker_connect_port = None diff --git a/lib/galaxy/web/base/interactive_environments.py b/lib/galaxy/web/base/interactive_environments.py index f9fdcf6fba3..599905ac5fb 100644 --- a/lib/galaxy/web/base/interactive_environments.py +++ b/lib/galaxy/web/base/interactive_environments.py @@ -42,6 +42,7 @@ class InteractiveEnvironmentRequest(object): self.load_deploy_config() self.load_allowed_images() self.attr.docker_hostname = self.attr.viz_config.get("docker", "docker_hostname") + self.attr.docker_connect_port = self.attr.viz_config.get("docker", "docker_connect_port") or None # Generate per-request passwords the IE plugin can use to configure # the destination container. @@ -306,13 +307,22 @@ class InteractiveEnvironmentRequest(object): port_mappings = self.get_container_port_mapping(inspect_data) self.attr.docker_hostname = self.get_container_host(inspect_data) log.debug( "Container host: %s", self.attr.docker_hostname ) + host_port = None + if len(port_mappings) > 1: - log.warning("Don't know how to handle proxies to containers with multiple exposed ports. Arbitrarily choosing first") + if self.attr.docker_connect_port is not None: + for _service, _host_ip, _host_port in port_mappings: + if _service == self.attr.docker_connect_port: + host_port = _host_port + else: + log.warning("Don't know how to handle proxies to containers with multiple exposed ports. Arbitrarily choosing first. Please set 'docker_connect_port' in your config file to be more specific.") elif len(port_mappings) == 0: log.warning("No exposed ports to map! Images MUST EXPOSE") return None - # Fetch the first port_mapping - (service, host_ip, host_port) = port_mappings[0] + + if host_port is None: + # Fetch the first port_mapping + (service, host_ip, host_port) = port_mappings[0] # Now we configure our proxy_requst object and we manually specify # the port to map to and ensure the proxy is available.