MCPcopy Index your code
hub / github.com/docker/docker-py / test_build_with_extra_hosts

Method test_build_with_extra_hosts

tests/integration/api_build_test.py:323–350  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

321
322 @requires_api_version('1.27')
323 def test_build_with_extra_hosts(self):
324 img_name = 'dockerpytest_extrahost_build'
325 self.tmp_imgs.append(img_name)
326
327 script = io.BytesIO('\n'.join([
328 'FROM busybox',
329 'RUN ping -c1 hello.world.test',
330 'RUN ping -c1 extrahost.local.test',
331 'RUN cp /etc/hosts /hosts-file'
332 ]).encode('ascii'))
333
334 stream = self.client.build(
335 fileobj=script, tag=img_name,
336 extra_hosts={
337 'extrahost.local.test': '127.0.0.1',
338 'hello.world.test': '127.0.0.1',
339 }, decode=True
340 )
341 for chunk in stream:
342 if 'errorDetail' in chunk:
343 pytest.fail(chunk)
344
345 assert self.client.inspect_image(img_name)
346 ctnr = self.run_container(img_name, 'cat /hosts-file')
347 logs = self.client.logs(ctnr)
348 logs = logs.decode('utf-8')
349 assert '127.0.0.1\textrahost.local.test' in logs
350 assert '127.0.0.1\thello.world.test' in logs
351
352 @requires_experimental(until=None)
353 @requires_api_version('1.25')

Callers

nothing calls this directly

Calls 5

joinMethod · 0.80
inspect_imageMethod · 0.80
buildMethod · 0.45
run_containerMethod · 0.45
logsMethod · 0.45

Tested by

no test coverage detected