Class: Train::Transports::Docker::Connection

Inherits:
BaseConnection
  • Object
show all
Defined in:
lib/train/transports/docker.rb

Instance Method Summary collapse

Constructor Details

#initialize(conf) ⇒ Connection

Returns a new instance of Connection.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/train/transports/docker.rb', line 54

def initialize(conf)
  super(conf)
  @id = options[:host]

  docker_url = options[:docker_url]
  if RUBY_PLATFORM =~ /windows|mswin|msys|mingw|cygwin/
    # Docker Desktop for windows. Must override socket location.
    # https://docs.docker.com/desktop/faqs/#how-do-i-connect-to-the-remote-docker-engine-api
    # docker_socket ||= "npipe:////./pipe/docker_engine" # # Doesn't require a settings change, but also doesn't work
    docker_url ||= "tcp://localhost:2375"
  end
  Docker.url = docker_url if docker_url

  @container = ::Docker::Container.get(@id) ||
    raise("Can't find Docker container #{@id}")
  @cmd_wrapper = nil
  @cmd_wrapper = CommandWrapper.load(self, @options)
  @probably_windows = nil
end

Instance Method Details

#closeObject



74
75
76
# File 'lib/train/transports/docker.rb', line 74

def close
  # nothing to do at the moment
end

#uriObject



78
79
80
81
82
83
84
# File 'lib/train/transports/docker.rb', line 78

def uri
  if @container.nil?
    "docker://#{@id}"
  else
    "docker://#{@container.id}"
  end
end