Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
network_disabled=False, name=None, entrypoint=None,
cpu_shares=None, working_dir=None, domainname=None,
memswap_limit=0, cpuset=None, host_config=None,
mac_address=None):
mac_address=None, labels=None):

if isinstance(volumes, six.string_types):
volumes = [volumes, ]
Expand All @@ -458,7 +458,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
self._version, image, command, hostname, user, detach, stdin_open,
tty, mem_limit, ports, environment, dns, volumes, volumes_from,
network_disabled, entrypoint, cpu_shares, working_dir, domainname,
memswap_limit, cpuset, host_config, mac_address
memswap_limit, cpuset, host_config, mac_address, labels
)
return self.create_container_from_config(config, name)

Expand Down
15 changes: 13 additions & 2 deletions docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -453,6 +454,15 @@ def create_container_config(
for k, v in six.iteritems(environment)
]

if isinstance(labels, six.string_types):
labels = [labels, ]

if isinstance(labels, list):
labels_dict = {}
for lbl in labels:
labels_dict[lbl] = {}
labels = labels_dict

if isinstance(mem_limit, six.string_types):
mem_limit = parse_bytes(mem_limit)
if isinstance(memswap_limit, six.string_types):
Expand Down Expand Up @@ -532,5 +542,6 @@ def create_container_config(
'WorkingDir': working_dir,
'MemorySwap': memswap_limit,
'HostConfig': host_config,
'MacAddress': mac_address
'MacAddress': mac_address,
'Labels': labels
}