Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions lib/kitchen/docker/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,27 @@ def create(state)
end

state[:username] = @config[:username]
state[:hostname] = 'localhost'
end

def destroy(state)
info("[Docker] Destroying Docker container #{state[:container_id]}") if state[:container_id]
remove_container(state) if container_exists?(state)

if @config[:remove_images] && state[:image_id]
remove_image(state) if image_exists?(state)
end
end

def hostname(state)
hostname = 'localhost'

if remote_socket?
state[:hostname] = socket_uri.host
elsif config[:use_internal_docker_network]
state[:hostname] = container_ip_address(state)
hostname = socket_uri.host
elsif @config[:use_internal_docker_network]
hostname = container_ip_address(state)
end

hostname
end

def upload(locals, remote)
Expand All @@ -56,15 +70,6 @@ def upload(locals, remote)

files
end

def destroy(state)
info("[Docker] Destroying Docker container #{state[:container_id]}") if state[:container_id]
remove_container(state) if container_exists?(state)

if @config[:remove_images] && state[:image_id]
remove_image(state) if image_exists?(state)
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/kitchen/docker/container/linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create(state)
state[:ssh_key] = @config[:private_key]
state[:image_id] = build_image(state, dockerfile) unless state[:image_id]
state[:container_id] = run_container(state, 22) unless state[:container_id]
state[:hostname] = 'localhost'
state[:hostname] = hostname(state)
state[:port] = container_ssh_port(state)
end

Expand Down
1 change: 1 addition & 0 deletions lib/kitchen/docker/container/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def create(state)
state[:username] = @config[:username]
state[:image_id] = build_image(state, dockerfile) unless state[:image_id]
state[:container_id] = run_container(state) unless state[:container_id]
state[:hostname] = hostname(state)
end

def execute(command)
Expand Down