From c78ba6f6982b5f7390635ba42dbb571b3900d333 Mon Sep 17 00:00:00 2001 From: anti Date: Thu, 30 Apr 2026 11:54:00 -0400 Subject: [PATCH] fix(deploy): pre-remove container by name before force-recreate Docker Compose tracks the previous container by internal ID. When that container was already removed or renamed, --force-recreate fails with "No such container". Remove by name first so Compose always starts clean. --- decnet/engine/services_live.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/decnet/engine/services_live.py b/decnet/engine/services_live.py index 936c7c63..271d8e1c 100644 --- a/decnet/engine/services_live.py +++ b/decnet/engine/services_live.py @@ -21,6 +21,7 @@ are documented in ``wiki-checkout/Service-Bus.md``. """ from __future__ import annotations +import subprocess # nosec B404 from pathlib import Path from typing import Any, Literal, Optional @@ -602,6 +603,16 @@ async def _update_fleet_service_config( await _redispatch_fleet_shard(repo, swarm_host_uuid) else: target = f"{decky_name}-{service_name}" + # Docker Compose tracks the previous container by ID. If that + # container was already removed (or renamed during a prior failed + # deploy), --force-recreate fails with "No such container". Pre- + # remove by name so Compose starts from a clean slate. + await anyio.to_thread.run_sync( + lambda: subprocess.run( # nosec B603 B607 + ["docker", "rm", "-f", target], + capture_output=True, + ), + ) await anyio.to_thread.run_sync( lambda: _compose( "up", "-d", "--no-deps", "--force-recreate", "--build", target,