docker/compose: quote health-cmd
Healthcheck commands need to be quoted to avoid Docker interpreting the cmd as arguments of CLI. This patch prevents that, and also test it in unit tests. Change-Id: I8273684716df0dbe6f58608d1915e0c9c17493b3 Closes-Bug: #1824808
This commit is contained in:
parent
61c448d7bc
commit
affc28f515
|
@ -44,7 +44,7 @@ class ComposeV1Builder(base.BaseBuilder):
|
|||
if 'healthcheck' in cconfig:
|
||||
hconfig = cconfig['healthcheck']
|
||||
if 'test' in hconfig:
|
||||
cmd.append('--health-cmd=%s' % hconfig['test'])
|
||||
cmd.append('--health-cmd="%s"' % hconfig['test'])
|
||||
if 'interval' in hconfig:
|
||||
cmd.append('--health-interval=%s' % hconfig['interval'])
|
||||
if 'timeout' in hconfig:
|
||||
|
|
|
@ -29,7 +29,7 @@ class TestComposeV1Builder(tbb.TestBaseBuilder):
|
|||
'uts': 'host',
|
||||
'restart': 'always',
|
||||
'healthcheck': {
|
||||
'test': '/bin/true',
|
||||
'test': 'ls /mydir',
|
||||
'interval': '30s',
|
||||
'timeout': '10s',
|
||||
'retries': 3
|
||||
|
@ -53,7 +53,7 @@ class TestComposeV1Builder(tbb.TestBaseBuilder):
|
|||
['docker', 'run', '--name', 'one',
|
||||
'--detach=true', '--env-file=/tmp/foo.env',
|
||||
'--net=host', '--ipc=host', '--pid=container:bar',
|
||||
'--uts=host', '--health-cmd=/bin/true', '--health-interval=30s',
|
||||
'--uts=host', '--health-cmd="ls /mydir"', '--health-interval=30s',
|
||||
'--health-timeout=10s', '--health-retries=3',
|
||||
'--privileged=true', '--restart=always', '--user=bar',
|
||||
'--log-opt=tag={{.ImageName}}/{{.Name}}/{{.ID}}',
|
||||
|
|
Loading…
Reference in New Issue