View Source DockerEngineAPI.Api.Network (testcontainers v1.11.6)

API calls for all endpoints tagged Network.

Summary

Functions

Disconnect a container from a network

List networks Returns a list of networks. For details on the format, see the network inspect endpoint. 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.

Delete unused networks

Functions

Link to this function

network_connect(connection, id, container, opts \\ [])

View Source

Connect a container to a network

Parameters

  • connection (DockerEngineAPI.Connection): Connection to server
  • id (String.t): Network ID or name
  • container (NetworkConnectRequest):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

network_create(connection, network_config, opts \\ [])

View Source

Create a network

Parameters

  • connection (DockerEngineAPI.Connection): Connection to server
  • network_config (NetworkCreateRequest): Network configuration
  • opts (keyword): Optional parameters

Returns

  • {:ok, DockerEngineAPI.Model.NetworkCreateResponse.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

network_delete(connection, id, opts \\ [])

View Source
@spec network_delete(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, nil}
  | {:ok, DockerEngineAPI.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Remove a network

Parameters

  • connection (DockerEngineAPI.Connection): Connection to server
  • id (String.t): Network ID or name
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

network_disconnect(connection, id, container, opts \\ [])

View Source
@spec network_disconnect(
  Tesla.Env.client(),
  String.t(),
  DockerEngineAPI.Model.NetworkDisconnectRequest.t(),
  keyword()
) ::
  {:ok, nil}
  | {:ok, DockerEngineAPI.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Disconnect a container from a network

Parameters

  • connection (DockerEngineAPI.Connection): Connection to server
  • id (String.t): Network ID or name
  • container (NetworkDisconnectRequest):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

network_inspect(connection, id, opts \\ [])

View Source
@spec network_inspect(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, DockerEngineAPI.Model.Network.t()}
  | {:ok, DockerEngineAPI.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Inspect a network

Parameters

  • connection (DockerEngineAPI.Connection): Connection to server
  • id (String.t): Network ID or name
  • opts (keyword): Optional parameters
    • :verbose (boolean()): Detailed inspect output for troubleshooting
    • :scope (String.t): Filter the network by scope (swarm, global, or local)

Returns

  • {:ok, DockerEngineAPI.Model.Network.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

network_list(connection, opts \\ [])

View Source
@spec network_list(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, DockerEngineAPI.Model.ErrorResponse.t()}
  | {:ok, [DockerEngineAPI.Model.Network.t()]}
  | {:error, Tesla.Env.t()}

List networks Returns a list of networks. For details on the format, see the network inspect endpoint. 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

  • connection (DockerEngineAPI.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :filters (String.t): JSON encoded value of the filters (a map[string][]string) to process on the networks list. Available filters: - dangling=<boolean> When set to true (or 1), returns all networks that are not in use by a container. When set to false (or 0), only networks that are in use by one or more containers are returned. - driver=<driver-name> Matches a network's driver. - id=<network-id> Matches all or part of a network ID. - label=<key> or label=<key>=<value> of a network label. - name=<network-name> Matches all or part of a network name. - scope=["swarm"|"global"|"local"] Filters networks by scope (swarm, global, or local). - type=["custom"|"builtin"] Filters networks by type. The custom keyword returns all user-defined networks.

Returns

  • {:ok, [%Network{}, ...]} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

network_prune(connection, opts \\ [])

View Source

Delete unused networks

Parameters

  • connection (DockerEngineAPI.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :filters (String.t): Filters to process on the prune list, encoded as JSON (a map[string][]string). Available filters: - until=<timestamp> Prune networks created before this timestamp. The <timestamp> can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. 10m, 1h30m) computed relative to the daemon machine’s time. - label (label=<key>, label=<key>=<value>, label!=<key>, or label!=<key>=<value>) Prune networks with (or without, in case label!=... is used) the specified labels.

Returns

  • {:ok, DockerEngineAPI.Model.NetworkPruneResponse.t} on success
  • {:error, Tesla.Env.t} on failure