From 1fe15a1cec97dcdaffd5d3dc0cfaa337fdeacefc Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Thu, 19 Mar 2026 19:25:48 +0000 Subject: [PATCH] Fix port check: only allow our own compose containers, not any Docker Previously any Docker process on the port was treated as safe. Now uses docker inspect on our project's containers specifically, so ports used by other apps on the server trigger the conflict prompt. Co-Authored-By: Claude Sonnet 4.6 --- deploy.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/deploy.sh b/deploy.sh index 004a49d..0d87f39 100755 --- a/deploy.sh +++ b/deploy.sh @@ -88,13 +88,17 @@ check_port() { return fi - # Check if it belongs to our own docker containers - local proc_name - proc_name=$(cat "/proc/${pid}/comm" 2>/dev/null || echo "unknown") + # Check if it belongs to OUR docker-compose project (not other apps on server) + local our_ids + our_ids=$(docker compose -f docker-compose.yml -f docker-compose.prod.yml ps -q 2>/dev/null || true) - if [[ "$proc_name" == "docker"* ]] || [[ "$proc_name" == "containerd"* ]]; then - info " Port $port ($service): used by Docker (will be replaced on restart)" - return + if [[ -n "$our_ids" ]]; then + # shellcheck disable=SC2086 + if docker inspect $our_ids 2>/dev/null \ + | grep -q "\"HostPort\": \"${port}\""; then + info " Port $port ($service): used by our container (will be replaced on restart)" + return + fi fi warn " Port $port ($service) is in use by PID $pid ($proc_name)"