From cbc7623ea09fd63a75f74378da11bd7cf266e32c Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 2 Aug 2018 12:00:11 -0700 Subject: [PATCH] Allow user=0 to be passed in create_container Signed-off-by: Anthony Sottile --- docker/types/containers.py | 2 +- tests/unit/types_containers_test.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/unit/types_containers_test.py diff --git a/docker/types/containers.py b/docker/types/containers.py index e7841bcb..9dfea8ce 100644 --- a/docker/types/containers.py +++ b/docker/types/containers.py @@ -578,7 +578,7 @@ class ContainerConfig(dict): 'Hostname': hostname, 'Domainname': domainname, 'ExposedPorts': ports, - 'User': six.text_type(user) if user else None, + 'User': six.text_type(user) if user is not None else None, 'Tty': tty, 'OpenStdin': stdin_open, 'StdinOnce': stdin_once, diff --git a/tests/unit/types_containers_test.py b/tests/unit/types_containers_test.py new file mode 100644 index 00000000..b0ad0a71 --- /dev/null +++ b/tests/unit/types_containers_test.py @@ -0,0 +1,6 @@ +from docker.types.containers import ContainerConfig + + +def test_uid_0_is_not_elided(): + x = ContainerConfig(image='i', version='v', command='true', user=0) + assert x['User'] == '0'