From 3f10533dbd41245bc111ff9f9d81a0540574a326 Mon Sep 17 00:00:00 2001 From: Meghdad <61308304+MeghdadFadaee@users.noreply.github.com> Date: Thu, 13 Aug 2026 03:35:36 +0330 Subject: [PATCH] fix(installer): add Compose plugin to existing Docker installs --- README.md | 5 +++-- scripts/install-server.sh | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 20c00e3..75401a0 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,9 @@ The hostname's A/AAAA record must already point to the server and inbound port 80 must be reachable so Let's Encrypt can issue the certificate. The installer does not change DNS, PTR, provider firewall rules, SSH, or UFW. It detects unmanaged Nginx hostname conflicts and conflicting Docker packages instead of -overwriting or removing them. Use `--yes` only for a reviewed, non-interactive -installation. +overwriting or removing them. If Docker is already installed without Compose +v2, it adds the matching Compose package from the configured APT repositories. +Use `--yes` only for a reviewed, non-interactive installation. Visit the printed HTTPS URL and complete the browser wizard. After creating and testing a permanent administrator, finish the security setup: diff --git a/scripts/install-server.sh b/scripts/install-server.sh index 30bf44f..dda2cfb 100755 --- a/scripts/install-server.sh +++ b/scripts/install-server.sh @@ -199,6 +199,34 @@ install_base_packages() { python3-certbot-nginx } +package_is_installed() { + dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -Fq 'install ok installed' +} + +install_compose_for_existing_docker() { + local candidates=() + if package_is_installed docker-ce || package_is_installed docker-ce-cli; then + candidates=(docker-compose-plugin docker-compose-v2) + else + candidates=(docker-compose-v2 docker-compose-plugin) + fi + + local package + for package in "${candidates[@]}"; do + if apt-cache show "$package" >/dev/null 2>&1; then + log "Installing $package for the existing Docker Engine" + if apt-get install -y --no-install-recommends "$package" && \ + docker compose version >/dev/null 2>&1; then + systemctl enable --now docker + docker compose version + return + fi + fi + done + + die "Docker is installed, but no compatible Compose v2 package is available from the configured APT repositories" +} + install_docker() { if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then log "Docker Engine and Compose are already installed" @@ -207,12 +235,13 @@ install_docker() { fi if command -v docker >/dev/null 2>&1; then - die "Docker is installed without a working Compose plugin; resolve that installation before continuing" + install_compose_for_existing_docker + return fi local conflicting_packages=() package for package in docker.io docker-compose docker-compose-v2 podman-docker containerd runc; do - if dpkg-query -W -f='${Status}' "$package" 2>/dev/null | grep -Fq 'install ok installed'; then + if package_is_installed "$package"; then conflicting_packages+=("$package") fi done