diff --git a/tests/e2e/utils.py b/tests/e2e/utils.py index e118b0d110d5..d4a27334e92b 100644 --- a/tests/e2e/utils.py +++ b/tests/e2e/utils.py @@ -112,7 +112,6 @@ def run_container(self, **specs: dict[str, Any]) -> Container: specs["network"] = self.__network.name specs["labels"] = self.docker_labels specs["detach"] = True - specs["auto_remove"] = True if hasattr(self, "live_server_url"): specs.setdefault("environment", {}) specs["environment"]["AUTHENTIK_HOST"] = self.live_server_url @@ -136,7 +135,7 @@ def output_container_logs(self, container: Container | None = None): print("::endgroup::") def tearDown(self): - containers = self.docker_client.containers.list( + containers: list[Container] = self.docker_client.containers.list( filters={"label": ",".join(f"{x}={y}" for x, y in self.docker_labels.items())} ) for container in containers: @@ -145,6 +144,10 @@ def tearDown(self): container.kill() except DockerException: pass + try: + container.remove(force=True) + except DockerException: + pass self.__network.remove()