Class: Docker::API::Transport::Unix

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

Overview

A daemon reached over a unix domain socket, which is how Docker is reached on Linux and macOS by default.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#host_header

Constructor Details

#initialize(path:) ⇒ Unix

Returns a new instance of Unix.

Parameters:

  • path (String)

    the socket path, e.g. "/var/run/docker.sock"



16
17
18
19
# File 'lib/docker/api/transport/unix.rb', line 16

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

Instance Attribute Details

#pathString (readonly)

Returns the socket path.

Returns:

  • (String)

    the socket path



13
14
15
# File 'lib/docker/api/transport/unix.rb', line 13

def path
  @path
end

Instance Method Details

#connectIO

Returns a connected unix socket.

Returns:

  • (IO)

    a connected unix socket

Raises:



23
24
25
# File 'lib/docker/api/transport/unix.rb', line 23

def connect
  dial("unix://#{path}") { UNIXSocket.new(path) }
end

#to_sString Also known as: inspect

Returns:

  • (String)


28
29
30
# File 'lib/docker/api/transport/unix.rb', line 28

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