Skip to content

Commit ac3d554

Browse files
committed
add helper methods for detecting a remote docker host via the DOCKER_HOST env var
1 parent 1ac47e7 commit ac3d554

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • files/tools/vagrant/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/docker

files/tools/vagrant/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/docker/provider.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require "digest/md5"
22
require "fileutils"
33
require "thread"
4+
require "uri"
45

56
require "log4r"
67

@@ -132,6 +133,17 @@ def host_vm?
132133
end
133134
end
134135

136+
# This checks whether the host system is configured to talk to a remote
137+
# docker host by inspecting the `DOCKER_HOST` env var.
138+
def remote_docker_host?
139+
!ENV['DOCKER_HOST'].to_s.strip.empty?
140+
end
141+
142+
# Returns the host part from the `DOCKER_HOST` env var
143+
def remote_docker_host
144+
URI.parse(ENV['DOCKER_HOST']).host
145+
end
146+
135147
# Returns the forwarded SSH port on the host. If no port forwarding
136148
# for "ssh" is found we return nil
137149
def forwarded_ssh_host_port

0 commit comments

Comments
 (0)