Connect a container to a network. Args: container (str): container-id/name to be connected to the network net_id (str): network id aliases (:py:class:`list`): A list of aliases for this endpoint. Names in that list can be used wit
(self, container, net_id,
ipv4_address=None, ipv6_address=None,
aliases=None, links=None,
link_local_ips=None, driver_opt=None,
mac_address=None)
| 213 | |
| 214 | @check_resource('container') |
| 215 | def connect_container_to_network(self, container, net_id, |
| 216 | ipv4_address=None, ipv6_address=None, |
| 217 | aliases=None, links=None, |
| 218 | link_local_ips=None, driver_opt=None, |
| 219 | mac_address=None): |
| 220 | """ |
| 221 | Connect a container to a network. |
| 222 | |
| 223 | Args: |
| 224 | container (str): container-id/name to be connected to the network |
| 225 | net_id (str): network id |
| 226 | aliases (:py:class:`list`): A list of aliases for this endpoint. |
| 227 | Names in that list can be used within the network to reach the |
| 228 | container. Defaults to ``None``. |
| 229 | links (:py:class:`list`): A list of links for this endpoint. |
| 230 | Containers declared in this list will be linked to this |
| 231 | container. Defaults to ``None``. |
| 232 | ipv4_address (str): The IP address of this container on the |
| 233 | network, using the IPv4 protocol. Defaults to ``None``. |
| 234 | ipv6_address (str): The IP address of this container on the |
| 235 | network, using the IPv6 protocol. Defaults to ``None``. |
| 236 | link_local_ips (:py:class:`list`): A list of link-local |
| 237 | (IPv4/IPv6) addresses. |
| 238 | mac_address (str): The MAC address of this container on the |
| 239 | network. Defaults to ``None``. |
| 240 | """ |
| 241 | data = { |
| 242 | "Container": container, |
| 243 | "EndpointConfig": self.create_endpoint_config( |
| 244 | aliases=aliases, links=links, ipv4_address=ipv4_address, |
| 245 | ipv6_address=ipv6_address, link_local_ips=link_local_ips, |
| 246 | driver_opt=driver_opt, |
| 247 | mac_address=mac_address |
| 248 | ), |
| 249 | } |
| 250 | |
| 251 | url = self._url("/networks/{0}/connect", net_id) |
| 252 | res = self._post_json(url, data=data) |
| 253 | self._raise_for_status(res) |
| 254 | |
| 255 | @check_resource('container') |
| 256 | def disconnect_container_from_network(self, container, net_id, |