Add 'hostname' and 'extra_hosts' to docker

This change is a porting to docker of [1], so we can run the tripleo ci
zuul reproducer at [2] with both docker and podman using just paunch.

[1] https://review.opendev.org/#/c/656270/
[2] https://review.rdoproject.org/r/#/c/20488/

Change-Id: I354edf45c247369876ffd931cb7fe3a4122b9a3e
This commit is contained in:
Quique Llorente 2019-05-07 11:13:48 +02:00
parent e948fdce90
commit 19788779a5
3 changed files with 20 additions and 1 deletions

View File

@ -67,6 +67,10 @@ class ComposeV1Builder(base.BaseBuilder):
self.string_arg(cconfig, cmd, 'mem_swappiness', '--memory-swappiness')
self.string_arg(cconfig, cmd, 'security_opt', '--security-opt')
self.string_arg(cconfig, cmd, 'stop_signal', '--stop-signal')
self.string_arg(cconfig, cmd, 'hostname', '--hostname')
for extra_host in cconfig.get('extra_hosts', []):
if extra_host:
cmd.append('--add-host=%s' % extra_host)
self.string_arg(cconfig, cmd,
'stop_grace_period', '--stop-timeout',

View File

@ -42,7 +42,13 @@ class TestComposeV1Builder(tbb.TestBaseBuilder):
'mem_swappiness': '60',
'security_opt': 'label:disable',
'cap_add': ['SYS_ADMIN', 'SETUID'],
'cap_drop': ['NET_RAW']
'cap_drop': ['NET_RAW'],
'hostname': 'foohostname',
'extra_hosts': [
'foohost:127.0.0.1',
'barhost:127.0.0.2'
]
}
}
builder = compose1.ComposeV1Builder('foo', config, None)
@ -62,6 +68,9 @@ class TestComposeV1Builder(tbb.TestBaseBuilder):
'--memory-swap=1G',
'--memory-swappiness=60',
'--security-opt=label:disable',
'--hostname=foohostname',
'--add-host=foohost:127.0.0.1',
'--add-host=barhost:127.0.0.2',
'--cap-add=SYS_ADMIN', '--cap-add=SETUID', '--cap-drop=NET_RAW',
'centos:7'],
cmd

View File

@ -0,0 +1,6 @@
---
features:
- |
docker learns 'hostname' which maps to docker run --hostname and
'extra_hosts' mapping to docker run --add-host.