Class: Docker::API::Network
- Defined in:
- lib/docker/api/resources/network.rb
Overview
A network on the daemon.
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#connect(container, aliases: [], ipv4_address: nil, ipv6_address: nil) ⇒ self
Attach a container to this network.
-
#containers ⇒ Hash
Containers attached to this network, keyed by id.
- #disconnect(container, force: false) ⇒ self
-
#driver ⇒ String?
"bridge", "overlay", "host", and so on.
-
#ipv6? ⇒ Boolean
Whether the network has IPv6 enabled.
-
#name ⇒ String?
The network's name.
- #reload ⇒ self
- #remove ⇒ void
-
#subnets ⇒ Array<Hash>
The network's IPAM configuration.
Methods inherited from Resource
#==, #[], #hash, #id, #initialize, #partial?, #stale?, #to_s
Constructor Details
This class inherits a constructor from Docker::API::Resource
Instance Method Details
#connect(container, aliases: [], ipv4_address: nil, ipv6_address: nil) ⇒ self
Attach a container to this network.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/docker/api/resources/network.rb', line 50 def connect(container, aliases: [], ipv4_address: nil, ipv6_address: nil) endpoint = {} endpoint["Aliases"] = aliases unless aliases.nil? || aliases.empty? endpoint["IPAMConfig"] = { "IPv4Address" => ipv4_address, "IPv6Address" => ipv6_address }.compact endpoint.delete("IPAMConfig") if endpoint["IPAMConfig"].empty? body = { "Container" => container_id(container) } body["EndpointConfig"] = endpoint unless endpoint.empty? operations.network_connect(id: id, body: body) self end |
#containers ⇒ Hash
Returns containers attached to this network, keyed by id.
26 27 28 |
# File 'lib/docker/api/resources/network.rb', line 26 def containers detail("Containers") || {} end |
#disconnect(container, force: false) ⇒ self
68 69 70 71 72 73 |
# File 'lib/docker/api/resources/network.rb', line 68 def disconnect(container, force: false) operations.network_disconnect( id: id, body: { "Container" => container_id(container), "Force" => force } ) self end |
#driver ⇒ String?
Returns "bridge", "overlay", "host", and so on.
16 17 18 |
# File 'lib/docker/api/resources/network.rb', line 16 def driver detail("Driver") end |
#ipv6? ⇒ Boolean
Returns whether the network has IPv6 enabled.
21 22 23 |
# File 'lib/docker/api/resources/network.rb', line 21 def ipv6? detail("EnableIPv6") == true end |
#name ⇒ String?
Returns the network's name.
11 12 13 |
# File 'lib/docker/api/resources/network.rb', line 11 def name detail("Name") end |
#reload ⇒ self
36 37 38 |
# File 'lib/docker/api/resources/network.rb', line 36 def reload replace_raw(operations.network_inspect(id: id || name).json) end |
#remove ⇒ void
This method returns an undefined value.
76 77 78 79 |
# File 'lib/docker/api/resources/network.rb', line 76 def remove operations.network_delete(id: id) nil end |
#subnets ⇒ Array<Hash>
Returns the network's IPAM configuration.
31 32 33 |
# File 'lib/docker/api/resources/network.rb', line 31 def subnets detail("IPAM.Config") || [] end |