(self)
| 270 | |
| 271 | @requires_api_version('1.25') |
| 272 | def test_build_with_network_mode(self): |
| 273 | # Set up pingable endpoint on custom network |
| 274 | network = self.client.create_network(random_name())['Id'] |
| 275 | self.tmp_networks.append(network) |
| 276 | container = self.client.create_container(TEST_IMG, 'top') |
| 277 | self.tmp_containers.append(container) |
| 278 | self.client.start(container) |
| 279 | self.client.connect_container_to_network( |
| 280 | container, network, aliases=['pingtarget.docker'] |
| 281 | ) |
| 282 | |
| 283 | script = io.BytesIO('\n'.join([ |
| 284 | 'FROM busybox', |
| 285 | 'RUN ping -c1 pingtarget.docker' |
| 286 | ]).encode('ascii')) |
| 287 | |
| 288 | stream = self.client.build( |
| 289 | fileobj=script, network_mode=network, |
| 290 | tag='dockerpytest_customnetbuild' |
| 291 | ) |
| 292 | |
| 293 | self.tmp_imgs.append('dockerpytest_customnetbuild') |
| 294 | for _chunk in stream: |
| 295 | pass |
| 296 | |
| 297 | assert self.client.inspect_image('dockerpytest_customnetbuild') |
| 298 | |
| 299 | script.seek(0) |
| 300 | stream = self.client.build( |
| 301 | fileobj=script, network_mode='none', |
| 302 | tag='dockerpytest_nonebuild', nocache=True, decode=True |
| 303 | ) |
| 304 | |
| 305 | self.tmp_imgs.append('dockerpytest_nonebuild') |
| 306 | logs = list(stream) |
| 307 | assert 'errorDetail' in logs[-1] |
| 308 | assert logs[-1]['errorDetail']['code'] == 1 |
| 309 | |
| 310 | with pytest.raises(errors.NotFound): |
| 311 | self.client.inspect_image('dockerpytest_nonebuild') |
| 312 | |
| 313 | @requires_api_version('1.27') |
| 314 | def test_build_with_extra_hosts(self): |
nothing calls this directly
no test coverage detected