Skip to content

Commit 1d69768

Browse files
committed
Full support to networking config during container creation
Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
1 parent 576e47a commit 1d69768

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

docker/models/containers.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ContainerError, DockerException, ImageNotFound,
99
NotFound, create_unexpected_kwargs_error
1010
)
11-
from ..types import HostConfig
11+
from ..types import EndpointConfig, HostConfig, NetworkingConfig
1212
from ..utils import version_gte
1313
from .images import Image
1414
from .resource import Collection, Model
@@ -680,10 +680,32 @@ def run(self, image, command=None, stdout=True, stderr=False,
680680
This mode is incompatible with ``ports``.
681681
682682
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``.
687709
oom_kill_disable (bool): Whether to disable OOM killer.
688710
oom_score_adj (int): An integer value containing the score given
689711
to the container in order to tune OOM killer preferences.
@@ -1124,12 +1146,16 @@ def _create_container_args(kwargs):
11241146
host_config_kwargs['binds'] = volumes
11251147

11261148
network = kwargs.pop('network', None)
1127-
network_driver_opt = kwargs.pop('network_driver_opt', None)
1149+
network_config = kwargs.pop('network_config', None)
11281150
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
11311155

1132-
create_kwargs['networking_config'] = {network: network_configuration}
1156+
create_kwargs['networking_config'] = NetworkingConfig(
1157+
{network: network_configuration}
1158+
)
11331159
host_config_kwargs['network_mode'] = network
11341160

11351161
# All kwargs should have been consumed by this point, so raise

0 commit comments

Comments
 (0)