|
8 | 8 | ContainerError, DockerException, ImageNotFound,
|
9 | 9 | NotFound, create_unexpected_kwargs_error
|
10 | 10 | )
|
11 |
| -from ..types import HostConfig |
| 11 | +from ..types import EndpointConfig, HostConfig, NetworkingConfig |
12 | 12 | from ..utils import version_gte
|
13 | 13 | from .images import Image
|
14 | 14 | from .resource import Collection, Model
|
@@ -680,10 +680,32 @@ def run(self, image, command=None, stdout=True, stderr=False,
|
680 | 680 | This mode is incompatible with ``ports``.
|
681 | 681 |
|
682 | 682 | Incompatible with ``network``.
|
683 |
| - network_driver_opt (dict): A dictionary of options to provide |
684 |
| - to the network driver. Defaults to ``None``. Used in |
685 |
| - conjuction with ``network``. Incompatible |
686 |
| - with ``network_mode``. |
| 683 | + network_config (dict): A dictionary containing options that are |
| 684 | + passed to the network driver during the connection. |
| 685 | + Defaults to ``None``. |
| 686 | + The dictionary contains the following keys: |
| 687 | +
|
| 688 | + - ``aliases`` (:py:class:`list`): A list of aliases for |
| 689 | + the network endpoint. |
| 690 | + Names in that list can be used within the network to |
| 691 | + reach this container. Defaults to ``None``. |
| 692 | + - ``links`` (:py:class:`list`): A list of links for |
| 693 | + the network endpoint endpoint. |
| 694 | + Containers declared in this list will be linked to this |
| 695 | + container. Defaults to ``None``. |
| 696 | + - ``ipv4_address`` (str): The IP address to assign to |
| 697 | + this container on the network, using the IPv4 protocol. |
| 698 | + Defaults to ``None``. |
| 699 | + - ``ipv6_address`` (str): The IP address to assign to |
| 700 | + this container on the network, using the IPv6 protocol. |
| 701 | + Defaults to ``None``. |
| 702 | + - ``link_local_ips`` (:py:class:`list`): A list of link-local |
| 703 | + (IPv4/IPv6) addresses. |
| 704 | + - ``driver_opt`` (dict): A dictionary of options to provide to |
| 705 | + the network driver. Defaults to ``None``. |
| 706 | +
|
| 707 | + Used in conjuction with ``network``. |
| 708 | + Incompatible with ``network_mode``. |
687 | 709 | oom_kill_disable (bool): Whether to disable OOM killer.
|
688 | 710 | oom_score_adj (int): An integer value containing the score given
|
689 | 711 | to the container in order to tune OOM killer preferences.
|
@@ -1124,12 +1146,16 @@ def _create_container_args(kwargs):
|
1124 | 1146 | host_config_kwargs['binds'] = volumes
|
1125 | 1147 |
|
1126 | 1148 | network = kwargs.pop('network', None)
|
1127 |
| - network_driver_opt = kwargs.pop('network_driver_opt', None) |
| 1149 | + network_config = kwargs.pop('network_config', None) |
1128 | 1150 | if network:
|
1129 |
| - network_configuration = {'driver_opt': network_driver_opt} \ |
1130 |
| - if network_driver_opt else None |
| 1151 | + network_configuration = EndpointConfig( |
| 1152 | + host_config_kwargs['version'], |
| 1153 | + **network_config |
| 1154 | + ) if network_config else None |
1131 | 1155 |
|
1132 |
| - create_kwargs['networking_config'] = {network: network_configuration} |
| 1156 | + create_kwargs['networking_config'] = NetworkingConfig( |
| 1157 | + {network: network_configuration} |
| 1158 | + ) |
1133 | 1159 | host_config_kwargs['network_mode'] = network
|
1134 | 1160 |
|
1135 | 1161 | # All kwargs should have been consumed by this point, so raise
|
|
0 commit comments