Skip to content

Commit

Permalink
use container network if nested_docker
Browse files Browse the repository at this point in the history
trying host-to-container mode first does not work if using docker in docker
  • Loading branch information
alelindq committed Feb 25, 2022
1 parent 11b13f6 commit 320f9c6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/beaker/hypervisor/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,23 @@ def get_ssh_connection_info(container)
else
# The many faces of container networking

# Host to Container
port22 = network_settings.dig('PortBindings','22/tcp')
if port22.nil? && network_settings.key?('Ports')
port22 = network_settings.dig('Ports','22/tcp')
# Container to container
if nested_docker?
ip = network_settings['IPAddress']
port = 22 if ip && !ip.empty?
end
ip = port22[0]['HostIp'] if port22
port = port22[0]['HostPort'] if port22

# Container to container
# Host to Container
unless ip && port
ip = nil
port = nil

ip = network_settings['IPAddress']
port = 22 if ip && !ip.empty?
port22 = network_settings.dig('PortBindings','22/tcp')
if port22.nil? && network_settings.key?('Ports')
port22 = network_settings.dig('Ports','22/tcp')
end
ip = port22[0]['HostIp'] if port22
port = port22[0]['HostPort'] if port22
end

# Container through gateway
Expand Down

0 comments on commit 320f9c6

Please sign in to comment.