def run_good_attached(): container_name = 'test' img_registry = DefaultDockerRegistry() img = DockerImage('mike0sv/ebaklya', registry=img_registry) instance = DockerContainer(container_name, ports_mapping={80: 8080}) host = DockerHost() runner = DockerRunner() runner.run(instance, img, host, detach=False, rm=True)
def run_detached_and_remove(): container_name = 'test' img_registry = DefaultDockerRegistry() img = DockerImage('test_broken_image', registry=img_registry) instance = DockerContainer(container_name) host = DockerHost() runner = DockerRunner() runner.run(instance, img, host, detach=True, rm=True)
def run_attached(): container_name = 'test' img_registry = DefaultDockerRegistry() img = DockerImage('test_broken_image', registry=img_registry) instance = DockerContainer(container_name, ports_mapping={80: 8080}) host = DockerHost() runner = DockerRunner() runner.run(instance, img, host, detach=False, rm=False)
def _check_runner(runner, img, host='', **kwargs): runner = runner(host, img, CONTAINER_NAME) instance = DockerContainer(CONTAINER_NAME, ports_mapping={80: 8080}) env = DockerHost(host) assert not runner.is_running(instance, env) runner.run(instance, img, env, **kwargs) time.sleep(.1) assert runner.is_running(instance, env) runner.stop(instance, env) time.sleep(.1) assert not runner.is_running(instance, env)