def _start_container(self, ssl_folder: str) -> Container: client: DockerClient = from_env() container = client.containers.run( image="library/docker:dind", detach=True, network_mode="host", remove=True, privileged=True, healthcheck=Healthcheck( test=["CMD", "docker", "info"], interval=5 * 100 * 1000000, start_period=5 * 100 * 1000000, ), environment={"DOCKER_TLS_CERTDIR": "/ssl"}, volumes={ f"{ssl_folder}/": { "bind": "/ssl", } }, ) while True: container.reload() status = container.attrs.get("State", {}).get("Health", {}).get("Status") if status == "healthy": return container sleep(1)
def _service_healthcheck(self): """ Converts the parameters in healthcheck into a Healthcheck class as expected by docker-py lib. """ healthcheck = self.healthcheck.copy() self.healthcheck = Healthcheck( test=healthcheck.get('test'), interval=convert_time_to_nano_secs(healthcheck.get('interval')) or 0, timeout=convert_time_to_nano_secs(healthcheck.get('timeout')) or 0, retries=healthcheck.get('retries'), start_period=convert_time_to_nano_secs( healthcheck.get('start_period')) or 0)