diff options
| author | Joffrey F <joffrey@docker.com> | 2015-03-20 16:17:38 -0700 |
|---|---|---|
| committer | Joffrey F <joffrey@docker.com> | 2015-03-20 16:17:38 -0700 |
| commit | 70ce156e26d283d181e6ec10bd1309ddc1da1bbd (patch) | |
| tree | 457c44f908903946944352554054e71716c24ba4 /docker/utils/utils.py | |
| parent | adf5a1cfc659c0f162485bc10f56b1bf0b0791ee (diff) | |
| parent | 96440cccb0fb1f627a3066025bdec264ca41cf16 (diff) | |
| download | docker-py-70ce156e26d283d181e6ec10bd1309ddc1da1bbd.tar.gz | |
Merge branch 'master' of github.com:docker/docker-py
Diffstat (limited to 'docker/utils/utils.py')
| -rw-r--r-- | docker/utils/utils.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py index 6abde98..63cd2a7 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -443,7 +443,8 @@ def create_container_config( stdin_open=False, tty=False, mem_limit=0, ports=None, environment=None, dns=None, volumes=None, volumes_from=None, network_disabled=False, entrypoint=None, cpu_shares=None, working_dir=None, domainname=None, - memswap_limit=0, cpuset=None, host_config=None, mac_address=None + memswap_limit=0, cpuset=None, host_config=None, mac_address=None, + labels=None ): if isinstance(command, six.string_types): command = shlex.split(str(command)) @@ -453,6 +454,14 @@ def create_container_config( for k, v in six.iteritems(environment) ] + if labels is not None and compare_version('1.18', version) < 0: + raise errors.DockerException( + 'labels were only introduced in API version 1.18' + ) + + if isinstance(labels, list): + labels = dict((lbl, six.text_type('')) for lbl in labels) + if isinstance(mem_limit, six.string_types): mem_limit = parse_bytes(mem_limit) if isinstance(memswap_limit, six.string_types): @@ -532,5 +541,6 @@ def create_container_config( 'WorkingDir': working_dir, 'MemorySwap': memswap_limit, 'HostConfig': host_config, - 'MacAddress': mac_address + 'MacAddress': mac_address, + 'Labels': labels } |
