Connect a container to this network. Args: container (str): Container to connect to this network, as either an ID, name, or :py:class:`~docker.models.containers.Container` object. aliases (:py:class:`list`): A list of aliases
(self, container, *args, **kwargs)
| 27 | ] |
| 28 | |
| 29 | def connect(self, container, *args, **kwargs): |
| 30 | """ |
| 31 | Connect a container to this network. |
| 32 | |
| 33 | Args: |
| 34 | container (str): Container to connect to this network, as either |
| 35 | an ID, name, or :py:class:`~docker.models.containers.Container` |
| 36 | object. |
| 37 | aliases (:py:class:`list`): A list of aliases for this endpoint. |
| 38 | Names in that list can be used within the network to reach the |
| 39 | container. Defaults to ``None``. |
| 40 | links (:py:class:`list`): A list of links for this endpoint. |
| 41 | Containers declared in this list will be linkedto this |
| 42 | container. Defaults to ``None``. |
| 43 | ipv4_address (str): The IP address of this container on the |
| 44 | network, using the IPv4 protocol. Defaults to ``None``. |
| 45 | ipv6_address (str): The IP address of this container on the |
| 46 | network, using the IPv6 protocol. Defaults to ``None``. |
| 47 | link_local_ips (:py:class:`list`): A list of link-local (IPv4/IPv6) |
| 48 | addresses. |
| 49 | driver_opt (dict): A dictionary of options to provide to the |
| 50 | network driver. Defaults to ``None``. |
| 51 | |
| 52 | Raises: |
| 53 | :py:class:`docker.errors.APIError` |
| 54 | If the server returns an error. |
| 55 | """ |
| 56 | if isinstance(container, Container): |
| 57 | container = container.id |
| 58 | return self.client.api.connect_container_to_network( |
| 59 | container, self.id, *args, **kwargs |
| 60 | ) |
| 61 | |
| 62 | def disconnect(self, container, *args, **kwargs): |
| 63 | """ |