MCPcopy
hub / github.com/docker/docker-py / list

Method list

docker/models/networks.py:185–214  ·  view source on GitHub ↗

List networks. Similar to the ``docker network ls`` command. Args: names (:py:class:`list`): List of names to filter by. ids (:py:class:`list`): List of ids to filter by. filters (dict): Filters to be processed on the network list.

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

183 )
184
185 def list(self, *args, **kwargs):
186 """
187 List networks. Similar to the ``docker network ls`` command.
188
189 Args:
190 names (:py:class:`list`): List of names to filter by.
191 ids (:py:class:`list`): List of ids to filter by.
192 filters (dict): Filters to be processed on the network list.
193 Available filters:
194 - ``driver=[<driver-name>]`` Matches a network&#x27;s driver.
195 - `label` (str|list): format either ``"key"``, ``"key=value"``
196 or a list of such.
197 - ``type=["custom"|"builtin"]`` Filters networks by type.
198 greedy (bool): Fetch more details for each network individually.
199 You might want this to get the containers attached to them.
200
201 Returns:
202 (list of :py:class:`Network`) The networks on the server.
203
204 Raises:
205 :py:class:`docker.errors.APIError`
206 If the server returns an error.
207 """
208 greedy = kwargs.pop('greedy', False)
209 resp = self.client.api.networks(*args, **kwargs)
210 networks = [self.prepare_model(item) for item in resp]
211 if greedy and version_gte(self.client.api._version, '1.28'):
212 for net in networks:
213 net.reload()
214 return networks
215
216 def prune(self, filters=None):
217 return self.client.api.prune_networks(filters=filters)

Callers

nothing calls this directly

Calls 4

version_gteFunction · 0.85
prepare_modelMethod · 0.80
networksMethod · 0.45
reloadMethod · 0.45

Tested by

no test coverage detected