Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "Gateway" from docker inspect as default docker_hostname #1770

Merged
merged 4 commits into from
Feb 22, 2016
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/galaxy/web/base/interactive_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ def launch(self, raw_cmd=None, env_override={}, volumes=[]):
return None
else:
log.debug( "Container id: %s" % stdout)
port_mappings = self.get_proxied_ports(stdout)
port_mappings, gateway_ip = self.get_proxied_ports(stdout)
if self.attr.docker_hostname == 'localhost':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm ok with this, since it only affects situations in which docker_hostname is localhost, so none of the ones that @bgruening or @natefoo encounter where docker is isolated on another host, but I'd rather they chime in since it affects them as well.

self.attr.docker_hostname = gateway_ip
if len(port_mappings) > 1:
log.warning("Don't know how to handle proxies to containers with multiple exposed ports. Arbitrarily choosing first")
elif len(port_mappings) == 0:
Expand Down Expand Up @@ -284,6 +286,7 @@ def get_proxied_ports(self, container_id):
# "HostPort" : "3306"
# }
# ]
gateway_ip = inspect_data[0]['NetworkSettings']['Gateway']
mappings = []
port_mappings = inspect_data[0]['NetworkSettings']['Ports']
for port_name in port_mappings:
Expand All @@ -293,4 +296,4 @@ def get_proxied_ports(self, container_id):
binding['HostIp'],
binding['HostPort']
))
return mappings
return mappings, gateway_ip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A future version of this should probably split out the mapping adjustments into a separate method, and then just return inspect_data here.