Class: DockerEngineAPI::Resources::Networks

Inherits:
Object
  • Object
show all
Defined in:
lib/docker_engine_api/resources/networks.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Networks

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Networks.

Parameters:



213
214
215
# File 'lib/docker_engine_api/resources/networks.rb', line 213

def initialize(client:)
  @client = client
end

Instance Method Details

#connect(id, container:, endpoint_config: nil, request_options: {}) ⇒ nil

The network must be either a local-scoped network or a swarm-scoped network with the attachable option set. A network cannot be re-attached to a running container

Parameters:

Returns:

  • (nil)

See Also:



122
123
124
125
126
127
128
129
130
131
# File 'lib/docker_engine_api/resources/networks.rb', line 122

def connect(id, params)
  parsed, options = DockerEngineAPI::NetworkConnectParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["networks/%1$s/connect", id],
    body: parsed,
    model: NilClass,
    options: options
  )
end

#create(name:, attachable: nil, config_from: nil, config_only: nil, driver: nil, enable_i_pv4: nil, enable_i_pv6: nil, ingress: nil, internal: nil, ipam: nil, labels: nil, options: nil, scope: nil, request_options: {}) ⇒ DockerEngineAPI::Models::CreateResponse

Some parameter documentations has been truncated, see Models::NetworkCreateParams for more details.

Create a network

Parameters:

  • name (String)

    The network’s name.

  • attachable (Boolean)

    Globally scoped network is manually attachable by regular

  • config_from (DockerEngineAPI::Models::NetworkCreateParams::ConfigFrom)

    The config-only network source to provide the configuration for

  • config_only (Boolean)

    Creates a config-only network. Config-only networks are placeholder

  • driver (String)

    Name of the network driver plugin to use.

  • enable_i_pv4 (Boolean)

    Enable IPv4 on the network.

  • enable_i_pv6 (Boolean)

    Enable IPv6 on the network.

  • ingress (Boolean)

    Ingress network is the network which provides the routing-mesh

  • internal (Boolean)

    Restrict external access to the network.

  • ipam (DockerEngineAPI::Models::NetworkCreateParams::Ipam)
  • labels (Hash{Symbol=>String})

    User-defined key/value metadata.

  • options (Hash{Symbol=>String})

    Network specific options to be used by the drivers.

  • scope (String)

    The level at which the network exists (e.g. swarm for cluster-wide

  • request_options (DockerEngineAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



44
45
46
47
48
49
50
51
52
53
# File 'lib/docker_engine_api/resources/networks.rb', line 44

def create(params)
  parsed, options = DockerEngineAPI::NetworkCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "networks/create",
    body: parsed,
    model: DockerEngineAPI::CreateResponse,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ nil

Remove a network

Parameters:

Returns:

  • (nil)

See Also:



96
97
98
99
100
101
102
103
# File 'lib/docker_engine_api/resources/networks.rb', line 96

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["networks/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#disconnect(id, container:, force: nil, request_options: {}) ⇒ nil

Disconnect a container from a network

Parameters:

  • id (String)

    Network ID or name

  • container (String)

    The ID or name of the container to disconnect from the network.

  • force (Boolean)

    Force the container to disconnect from the network.

  • request_options (DockerEngineAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



148
149
150
151
152
153
154
155
156
157
# File 'lib/docker_engine_api/resources/networks.rb', line 148

def disconnect(id, params)
  parsed, options = DockerEngineAPI::NetworkDisconnectParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["networks/%1$s/disconnect", id],
    body: parsed,
    model: NilClass,
    options: options
  )
end

#inspect_(id, scope: nil, verbose: nil, request_options: {}) ⇒ DockerEngineAPI::Models::NetworkInspectResponse

Inspect a network

Parameters:

  • id (String)

    Network ID or name

  • scope (String)

    Filter the network by scope (swarm, global, or local)

  • verbose (Boolean)

    Detailed inspect output for troubleshooting

  • request_options (DockerEngineAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



174
175
176
177
178
179
180
181
182
183
# File 'lib/docker_engine_api/resources/networks.rb', line 174

def inspect_(id, params = {})
  parsed, options = DockerEngineAPI::NetworkInspectParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["networks/%1$s", id],
    query: parsed,
    model: DockerEngineAPI::Models::NetworkInspectResponse,
    options: options
  )
end

#list(filters: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::Summary>

Some parameter documentations has been truncated, see Models::NetworkListParams for more details.

Returns a list of networks. For details on the format, see the [network inspect endpoint](#operation/NetworkInspect).

Note that it uses a different, smaller representation of a network than inspecting a single network. For example, the list of containers attached to the network is not propagated in API versions 1.28 and up.

Parameters:

  • filters (String)

    JSON encoded value of the filters (a map[string][]string) to process

  • request_options (DockerEngineAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



74
75
76
77
78
79
80
81
82
83
# File 'lib/docker_engine_api/resources/networks.rb', line 74

def list(params = {})
  parsed, options = DockerEngineAPI::NetworkListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "networks",
    query: parsed,
    model: DockerEngineAPI::Internal::Type::ArrayOf[DockerEngineAPI::Summary],
    options: options
  )
end

#prune(filters: nil, request_options: {}) ⇒ DockerEngineAPI::Models::NetworkPruneResponse

Some parameter documentations has been truncated, see Models::NetworkPruneParams for more details.

Delete unused networks

Parameters:

  • filters (String)

    Filters to process on the prune list, encoded as JSON (a map[string][]string).

  • request_options (DockerEngineAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



199
200
201
202
203
204
205
206
207
208
# File 'lib/docker_engine_api/resources/networks.rb', line 199

def prune(params = {})
  parsed, options = DockerEngineAPI::NetworkPruneParams.dump_request(params)
  @client.request(
    method: :post,
    path: "networks/prune",
    query: parsed,
    model: DockerEngineAPI::Models::NetworkPruneResponse,
    options: options
  )
end