From 5e74ce73a693d2a84e54607b10f1ebb91eedead3 Mon Sep 17 00:00:00 2001 From: Michael Schiemer Date: Mon, 24 Nov 2025 22:10:38 +0100 Subject: [PATCH] fix(deploy): force remove containers before deployment The --force-recreate flag alone doesn't handle containers that exist outside the compose project context. Now explicitly: 1. Run docker compose down first 2. Force remove any orphaned containers with known names 3. Then create fresh containers --- deployment/scripts/deploy.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/deployment/scripts/deploy.sh b/deployment/scripts/deploy.sh index 92f85651..e9b1798f 100755 --- a/deployment/scripts/deploy.sh +++ b/deployment/scripts/deploy.sh @@ -117,10 +117,20 @@ fi print_info "Pulling latest images..." docker compose $COMPOSE_FILES pull || print_warning "Failed to pull some images, continuing..." +# Stop and remove existing containers to prevent name conflicts +print_info "Stopping existing containers..." +docker compose $COMPOSE_FILES down --remove-orphans || print_warning "No existing containers to stop" + +# Remove any orphaned containers with conflicting names +for container in nginx php redis scheduler queue-worker; do + if docker ps -a --format '{{.Names}}' | grep -q "^${container}$"; then + print_warning "Removing orphaned container: $container" + docker rm -f "$container" 2>/dev/null || true + fi +done + # Deploy stack print_info "Deploying application stack..." -# --force-recreate: Recreate containers even if unchanged -# --remove-orphans: Remove containers for services not in compose file docker compose $COMPOSE_FILES up -d --force-recreate --remove-orphans # Wait for services to be healthy