networks¶
Model for Network resources.
Example
- with PodmanClient(base_url=”unix:///run/user/1000/podman/podman.sock”) as client:
- net = client.networks.get(“db_network”)
print(net.name, “
“)
- class Network(attrs: Mapping[str, Any] | None = None, client: APIClient | None = None, collection: Manager | None = None, podman_client: PodmanClient | None = None)[source]¶
Bases:
PodmanResourceDetails and configuration for a networks managed by the Podman service.
- attrs¶
Attributes of Network reported from Podman service
- Type:
dict[str, Any]
Initialize base class for PodmanResource’s.
- Parameters:
attrs – Mapping of attributes for resource from Podman service.
client – Configured connection to a Podman service.
collection – Manager of this category of resource, named collection for compatibility
podman_client – PodmanClient() configured to connect to Podman object.
- connect(container: str | Container, *_, **kwargs) None[source]¶
Connect given container to this network.
- Parameters:
container – To add to this Network
- Keyword Arguments:
aliases (list[str]) – Aliases to add for this endpoint
driver_opt (dict[str, Any]) – Options to provide to network driver
ipv4_address (str) – IPv4 address for given Container on this network
ipv6_address (str) – IPv6 address for given Container on this network
link_local_ips (list[str]) – list of link-local addresses
links (list[Union[str, Containers]]) – Ignored
- Raises:
APIError – when Podman service reports an error
- disconnect(container: str | Container, **kwargs) None[source]¶
Disconnect given container from this network.
- Parameters:
container – To remove from this Network
- Keyword Arguments:
force (bool) – Force operation
- Raises:
APIError – when Podman service reports an error
- remove(force: bool | None = None, **kwargs) None[source]¶
Remove this network.
- Parameters:
force – Remove network and any associated containers
- Raises:
APIError – when Podman service reports an error
- property containers¶
Returns list of Containers connected to network.
- Type:
list[Container]
- property id¶
Returns the identifier of the network.
- Type:
str
- property name¶
Returns the name of the network.
- Type:
str
- property short_id¶
Returns truncated identifier. ‘sha256’ preserved when included in the id.
No attempt is made to ensure the returned value is semantically meaningful for all resources.
- Type:
str