docker_container: do not split command on commas (#24900)

* docker_container: do not split command on commas

Fix issue #24430

* docker_container: document command parameter

Prior behavior was strange, splitting strings on commas
only to join them again ... replacing commas with spaces.

FYI, docker-py accepts strings or lists, using shlex.split
on strings ... splitting on spaces while respecting things
like quotes.

https://github.com/docker/docker-py/blob/master/docker/api/container.py
https://github.com/docker/docker-py/blob/master/docker/types/containers.py
https://github.com/docker/docker-py/blob/master/docker/utils/utils.py

More info regarding Dockerfile syntax for CMD strings and lists
can be found at https://docs.docker.com/engine/reference/builder/#cmd
pull/19187/head
Andrew Shewmaker 8 years ago committed by Toshio Kuratomi
parent f8e47e2204
commit f5fd32eae6

@ -59,6 +59,8 @@ options:
command: command:
description: description:
- Command to execute when the container starts. - Command to execute when the container starts.
A command may be either a string or a list.
Prior to version 2.4, strings were split on commas.
default: null default: null
required: false required: false
cpu_period: cpu_period:
@ -814,6 +816,7 @@ class TaskParameters(DockerBaseClass):
if self.command: if self.command:
# convert from list to str # convert from list to str
if isinstance(self.command, list):
self.command = ' '.join([str(x) for x in self.command]) self.command = ' '.join([str(x) for x in self.command])
def fail(self, msg): def fail(self, msg):
@ -1970,7 +1973,7 @@ def main():
blkio_weight=dict(type='int'), blkio_weight=dict(type='int'),
capabilities=dict(type='list'), capabilities=dict(type='list'),
cleanup=dict(type='bool', default=False), cleanup=dict(type='bool', default=False),
command=dict(type='list'), command=dict(type='raw'),
cpu_period=dict(type='int'), cpu_period=dict(type='int'),
cpu_quota=dict(type='int'), cpu_quota=dict(type='int'),
cpuset_cpus=dict(type='str'), cpuset_cpus=dict(type='str'),

Loading…
Cancel
Save