Handle attrs["State"]["ExitCode"]
MODIFY
repo2docker/app.py
repo2docker/app.py
@@ -607,7 +607,7 @@ class Repo2Docker(Application):
if container.status == "running":
self.log.info("Stopping container...\n", extra=dict(phase="running"))
container.kill()
- exit_code = container.attrs["State"]["ExitCode"]
+ exit_code = container.exitcode
container.wait()

MODIFY
repo2docker/docker.py
repo2docker/docker.py
@@ -25,6 +25,10 @@ class DockerContainer(Container):
def stop(self, *, timeout=10):
return self._c.stop(timeout=timeout)
+ @property
+ def exitcode(self):
+ return self._c.attrs["State"]["ExitCode"]
+
@property
def status(self):
return self._c.status

MODIFY
repo2docker/engine.py
repo2docker/engine.py
@@ -62,6 +62,13 @@ class Container(ABC):
timeout : If the container doesn't gracefully stop after this timeout kill it
"""
+ @property
+ @abstractmethod
+ def exitcode(self):
+ """
+ The container exit code if exited
+ """
+
@property
@abstractmethod
def status(self):

MODIFY
tests/unit/test_ports.py
tests/unit/test_ports.py
@@ -77,7 +77,7 @@ def read_port_mapping_response(
container.reload()
assert container.status == "running"
- port_mapping = container.attrs["NetworkSettings"]["Ports"]
+ port_mapping = container._c.attrs["NetworkSettings"]["Ports"]
if all_ports:
port = port_mapping["8888/tcp"][0]["HostPort"]

Handle attrs["State"]["ExitCode"]