From 2d58351164eba01e30569f44a921d5aca40163ae Mon Sep 17 00:00:00 2001 From: Johannes 'fish' Ziemke Date: Tue, 13 May 2014 20:15:31 +0200 Subject: [PATCH] Add NetMode to hostConfig in start --- README.md | 8 +++++++- docker/client.py | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f725db9f..c7414f6e 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ Identical to the `docker search` command. ```python c.start(container, binds=None, port_bindings=None, lxc_conf=None, publish_all_ports=False, links=None, privileged=False, - dns=None, volumes_from=None) + dns=None, volumes_from=None, network_mode=None) ``` Similar to the `docker start` command, but doesn't support attach @@ -233,6 +233,12 @@ specified as a dictionary mapping name to alias or as a list of `dns` and `volumes_from` are only available if they are used with version v1.10 of docker remote API. Otherwise they are ignored. +`network_mode` is available since v1.11 and sets the Network mode for the +container ('bridge': creates a new network stack for the container on the +docker bridge, 'none': no networking for this container, 'container:[name|id]': +reuses another container network stack), 'host': use the host network stack +inside the container. + ```python c.stop(container, timeout=10) ``` diff --git a/docker/client.py b/docker/client.py index 9f4d0a0c..54ae9f72 100644 --- a/docker/client.py +++ b/docker/client.py @@ -688,7 +688,7 @@ class Client(requests.Session): def start(self, container, binds=None, port_bindings=None, lxc_conf=None, publish_all_ports=False, links=None, privileged=False, - dns=None, volumes_from=None): + dns=None, volumes_from=None, network_mode=None): if isinstance(container, dict): container = container.get('Id') @@ -742,6 +742,9 @@ class Client(requests.Session): warnings.warn(warning_message.format('volumes_from'), DeprecationWarning) + if network_mode: + start_config['NetworkMode'] = network_mode + url = self._url("/containers/{0}/start".format(container)) res = self._post_json(url, data=start_config) self._raise_for_status(res)