Merge pull request #7840 from pstengel/bugfix/7651

Do better at finding ssh_info for Docker
This commit is contained in:
Chris Roberts 2017-04-03 14:41:50 -07:00 committed by GitHub
commit 74ad90d8e0
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