Do better at finding ssh_info for Docker

This commit is contained in:
Paul Stengel 2016-09-28 13:25:13 -04:00
parent d8c2b2e5ab
commit d98c5b8c00
1 changed files with 7 additions and 5 deletions

View File

@ -136,16 +136,18 @@ module VagrantPlugins
# If the container isn't running, we can't SSH into it
return nil if state.id != :running
network = driver.inspect_container(@machine.id)['NetworkSettings']
ip = network['IPAddress']
port_name = "#{@machine.config.ssh.guest_port}/tcp"
network = driver.inspect_container(@machine.id)['NetworkSettings']
port_info = network['Ports'][port_name].first
# If we were not able to identify the container's IP, we return nil
# here and we let Vagrant core deal with it ;)
return nil if !ip
return nil if port_info.nil? || port_info.empty?
{
host: ip,
port: @machine.config.ssh.guest_port
host: port_info['HostIp'],
port: port_info['HostPort']
}
end