Skip to content

Commit af492c3

Browse files
committed
Added support for pid_mode param
1 parent 22dd8d7 commit af492c3

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

docker/client.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ def create_container(self, image, command=None, hostname=None, user=None,
550550
config = self._container_config(
551551
image, command, hostname, user, detach, stdin_open, tty, mem_limit,
552552
ports, environment, dns, volumes, volumes_from, network_disabled,
553-
entrypoint, cpu_shares, working_dir, domainname,
554-
memswap_limit, cpuset, host_config, mac_address
553+
entrypoint, cpu_shares, working_dir, domainname, memswap_limit,
554+
cpuset, host_config, mac_address
555555
)
556556
return self.create_container_from_config(config, name)
557557

@@ -957,7 +957,7 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None,
957957
publish_all_ports=False, links=None, privileged=False,
958958
dns=None, dns_search=None, volumes_from=None, network_mode=None,
959959
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
960-
extra_hosts=None, read_only=None):
960+
extra_hosts=None, read_only=None, pid_mode=None):
961961

962962
if utils.compare_version('1.10', self._version) < 0:
963963
if dns is not None:
@@ -969,19 +969,23 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None,
969969
'volumes_from is only supported for API version >= 1.10'
970970
)
971971

972-
if utils.compare_version('1.17', self._version) < 0 and \
973-
read_only is not None:
974-
raise errors.InvalidVersion(
975-
'read_only is only supported for API version >= 1.17'
976-
)
972+
if utils.compare_version('1.17', self._version) < 0:
973+
if read_only is not None:
974+
raise errors.InvalidVersion(
975+
'read_only is only supported for API version >= 1.17'
976+
)
977+
if pid_mode is not None:
978+
raise errors.InvalidVersion(
979+
'pid_mode is only supported for API version >= 1.17'
980+
)
977981

978982
start_config = utils.create_host_config(
979983
binds=binds, port_bindings=port_bindings, lxc_conf=lxc_conf,
980984
publish_all_ports=publish_all_ports, links=links, dns=dns,
981985
privileged=privileged, dns_search=dns_search, cap_add=cap_add,
982986
cap_drop=cap_drop, volumes_from=volumes_from, devices=devices,
983987
network_mode=network_mode, restart_policy=restart_policy,
984-
extra_hosts=extra_hosts, read_only=read_only
988+
extra_hosts=extra_hosts, read_only=read_only, pid_mode=pid_mode
985989
)
986990

987991
if isinstance(container, dict):

docker/utils/utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,17 @@ def create_host_config(
309309
publish_all_ports=False, links=None, privileged=False,
310310
dns=None, dns_search=None, volumes_from=None, network_mode=None,
311311
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
312-
extra_hosts=None, read_only=None
312+
extra_hosts=None, read_only=None, pid_mode=None
313313
):
314314
host_config = {}
315315

316+
if pid_mode not in (None, 'host'):
317+
raise errors.DockerException(
318+
'Invalid value for pid param: {0}'.format(pid_mode)
319+
)
320+
elif pid_mode:
321+
host_config['PidMode'] = pid_mode
322+
316323
if privileged:
317324
host_config['Privileged'] = privileged
318325

0 commit comments

Comments
 (0)