Skip to content

Instantly share code, notes, and snippets.

@InTheCloudDan
Last active January 13, 2018 23:32
Show Gist options
  • Save InTheCloudDan/a9dadd8d106ddffa5359d3b7f48a8a2f to your computer and use it in GitHub Desktop.
Save InTheCloudDan/a9dadd8d106ddffa5359d3b7f48a8a2f to your computer and use it in GitHub Desktop.
def _docker(self, run_config):
def poll(self):
return True if self.status == "running" else False
def running(self):
pass
client = docker.from_env()
container = client.containers.run("s2client-game", ports={'12000': self._port}, detach=True,
healthcheck={"test": "netstat -anpt | grep 12000 || exit 1"})
container.poll = MethodType(docker.models.containers.Container, poll)
container.running = MethodType(docker.models.containers.Container, running)
health = docker.APIClient()
for i in range(60):
print(i)
if health.inspect_container(container.id)['State']['Health']['Status'] == "healthy":
break
else:
time.sleep(1)
return container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment