Skip to content

Commit

Permalink
add helper methods for detecting a remote docker host via the `DOCKER…
Browse files Browse the repository at this point in the history
…_HOST` env var
  • Loading branch information
tknerr committed Aug 7, 2015
1 parent b90c613 commit 2dd50b5
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "digest/md5"
require "fileutils"
require "thread"
require "uri"

require "log4r"

Expand Down Expand Up @@ -136,6 +137,17 @@ def host_vm?
end
end

# This checks whether the host system is configured to talk to a remote
# docker host by inspecting the `DOCKER_HOST` env var.
def remote_docker_host?
!ENV['DOCKER_HOST'].to_s.strip.empty?
end

# Returns the host part from the `DOCKER_HOST` env var
def remote_docker_host
URI.parse(ENV['DOCKER_HOST']).host
end

# Returns the forwarded SSH port on the host. If no port forwarding
# for "ssh" is found we return nil
def forwarded_ssh_host_port
Expand Down

0 comments on commit 2dd50b5

Please sign in to comment.