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)"