Class: Train::Transports::Docker::Connection
- Inherits:
-
BaseConnection
- Object
- BaseConnection
- Train::Transports::Docker::Connection
- Defined in:
- lib/train/transports/docker.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(conf) ⇒ Connection
constructor
A new instance of Connection.
- #unique_identifier ⇒ Object
- #uri ⇒ Object
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 = [:host] docker_url = [: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
#close ⇒ Object
74 75 76 |
# File 'lib/train/transports/docker.rb', line 74 def close # nothing to do at the moment end |
#unique_identifier ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/train/transports/docker.rb', line 86 def unique_identifier uuid = @container.nil? ? @id : @container.id # default uuid set to the docker host. unless sniff_for_windows? cmd = run_command_via_connection("head -1 /proc/self/cgroup|cut -d/ -f3") if file("/proc/self/cgroup").exist? unless cmd.stdout.empty? uuid = cmd.stdout.strip end end uuid end |
#uri ⇒ Object
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 |