mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 17:21:04 +00:00
Fix Docker container race condition during upgrades
Stop and remove existing Coolify containers before starting new ones to prevent conflicts when project name changes from 'source' to 'coolify'. This resolves volume and container name conflicts during upgrades from older installations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,17 @@ if [ -f /root/.docker/config.json ]; then
|
||||
DOCKER_CONFIG_MOUNT="-v /root/.docker/config.json:/root/.docker/config.json"
|
||||
fi
|
||||
|
||||
# Stop and remove existing Coolify containers to prevent conflicts
|
||||
# This handles both old installations (project "source") and new ones (project "coolify")
|
||||
echo "Stopping existing Coolify containers..." >>"$LOGFILE"
|
||||
for container in coolify coolify-db coolify-redis coolify-realtime; do
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "^${container}$"; then
|
||||
docker stop "$container" >>"$LOGFILE" 2>&1 || true
|
||||
docker rm "$container" >>"$LOGFILE" 2>&1 || true
|
||||
echo " - Removed container: $container" >>"$LOGFILE"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -f /data/coolify/source/docker-compose.custom.yml ]; then
|
||||
echo "docker-compose.custom.yml detected." >>"$LOGFILE"
|
||||
docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock ${DOCKER_CONFIG_MOUNT} --rm ${REGISTRY_URL:-ghcr.io}/coollabsio/coolify-helper:${LATEST_HELPER_VERSION} bash -c "LATEST_IMAGE=${LATEST_IMAGE} docker compose --project-name coolify --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml -f /data/coolify/source/docker-compose.custom.yml up -d --remove-orphans --wait --wait-timeout 60" >>"$LOGFILE" 2>&1
|
||||
|
||||
Reference in New Issue
Block a user