Add Container.wait()

pull/848/head
Simon Li 2021-02-21 00:19:54 +00:00
rodzic 5778ed0381
commit d47b74492f
2 zmienionych plików z 13 dodań i 4 usunięć

Wyświetl plik

@ -25,6 +25,9 @@ class DockerContainer(Container):
def stop(self, *, timeout=10): def stop(self, *, timeout=10):
return self._c.stop(timeout=timeout) return self._c.stop(timeout=timeout)
def wait(self):
return self._c.wait()
@property @property
def exitcode(self): def exitcode(self):
return self._c.attrs["State"]["ExitCode"] return self._c.attrs["State"]["ExitCode"]
@ -61,7 +64,7 @@ class DockerEngine(ContainerEngine):
dockerfile="", dockerfile="",
fileobj=None, fileobj=None,
path="", path="",
**kwargs **kwargs,
): ):
return self._apiclient.build( return self._apiclient.build(
buildargs=buildargs, buildargs=buildargs,
@ -99,7 +102,7 @@ class DockerEngine(ContainerEngine):
publish_all_ports=False, publish_all_ports=False,
remove=False, remove=False,
volumes=None, volumes=None,
**kwargs **kwargs,
): ):
client = docker.from_env(version="auto") client = docker.from_env(version="auto")
container = client.containers.run( container = client.containers.run(

Wyświetl plik

@ -62,6 +62,12 @@ class Container(ABC):
timeout : If the container doesn't gracefully stop after this timeout kill it timeout : If the container doesn't gracefully stop after this timeout kill it
""" """
@abstractmethod
def wait(self):
"""
Wait for the container to stop
"""
@property @property
@abstractmethod @abstractmethod
def exitcode(self): def exitcode(self):
@ -161,7 +167,7 @@ class ContainerEngine(LoggingConfigurable):
dockerfile="", dockerfile="",
fileobj=None, fileobj=None,
path="", path="",
**kwargs **kwargs,
): ):
""" """
Build a container Build a container
@ -255,7 +261,7 @@ class ContainerEngine(LoggingConfigurable):
publish_all_ports=False, publish_all_ports=False,
remove=False, remove=False,
volumes={}, volumes={},
**kwargs **kwargs,
): ):
""" """
Run a container Run a container