Class: Docker::API::Transport::NamedPipe

Inherits:
Base
  • Object
show all
Defined in:
lib/docker/api/transport/named_pipe.rb

Overview

A daemon reached over a Windows named pipe, which is how Docker Desktop for Windows exposes the Engine API by default.

Windows named pipes present as files, so a binary-mode File is a bidirectional stream that behaves closely enough to a socket for the layer above. This is the transport the docker-api gem never grew, which is why kitchen-dokken carries a standing TODO about Windows support.

Constant Summary collapse

DEFAULT_PIPE =

The pipe Docker Desktop for Windows publishes by default.

"//./pipe/docker_engine"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#host_header

Constructor Details

#initialize(path: DEFAULT_PIPE) ⇒ NamedPipe

Returns a new instance of NamedPipe.

Parameters:

  • path (String) (defaults to: DEFAULT_PIPE)

    the pipe path



24
25
26
27
# File 'lib/docker/api/transport/named_pipe.rb', line 24

def initialize(path: DEFAULT_PIPE)
  super()
  @path = path
end

Instance Attribute Details

#pathString (readonly)

Returns the pipe path.

Returns:

  • (String)

    the pipe path



21
22
23
# File 'lib/docker/api/transport/named_pipe.rb', line 21

def path
  @path
end

Instance Method Details

#connectIO

Returns the opened pipe.

Returns:

  • (IO)

    the opened pipe

Raises:



31
32
33
34
35
36
37
# File 'lib/docker/api/transport/named_pipe.rb', line 31

def connect
  dial("npipe://#{path}") do
    pipe = File.open(windows_path, "r+b")
    pipe.sync = true
    pipe
  end
end

#to_sString Also known as: inspect

Returns:

  • (String)


40
41
42
# File 'lib/docker/api/transport/named_pipe.rb', line 40

def to_s
  "#<Docker::API::Transport::NamedPipe path=#{path}>"
end