Split the entrypoint string to shell-like syntax.

This commit is contained in:
Colin Huang 2015-08-25 09:44:47 +08:00
parent 9bb6a6fd56
commit edebf3756a
2 changed files with 5 additions and 2 deletions

View File

@ -564,6 +564,9 @@ def create_container_config(
if isinstance(command, six.string_types): if isinstance(command, six.string_types):
command = shlex.split(str(command)) command = shlex.split(str(command))
if isinstance(entrypoint, six.string_types):
entrypoint = shlex.split(str(entrypoint))
if isinstance(environment, dict): if isinstance(environment, dict):
environment = [ environment = [
six.text_type('{0}={1}').format(k, v) six.text_type('{0}={1}').format(k, v)

View File

@ -428,7 +428,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
def test_create_container_with_entrypoint(self): def test_create_container_with_entrypoint(self):
try: try:
self.client.create_container('busybox', 'hello', self.client.create_container('busybox', 'hello',
entrypoint='cowsay') entrypoint='cowsay entry')
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: {0}'.format(e)) self.fail('Command should not raise exception: {0}'.format(e))
@ -443,7 +443,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
"AttachStdout": true, "OpenStdin": false, "AttachStdout": true, "OpenStdin": false,
"StdinOnce": false, "StdinOnce": false,
"NetworkDisabled": false, "NetworkDisabled": false,
"Entrypoint": "cowsay"}''')) "Entrypoint": ["cowsay", "entry"]}'''))
self.assertEqual(args[1]['headers'], self.assertEqual(args[1]['headers'],
{'Content-Type': 'application/json'}) {'Content-Type': 'application/json'})