Update docker-vm.sh

This commit is contained in:
CanbiZ 2025-11-11 14:16:01 +01:00
parent 8790e50daf
commit 978fe863c9

View File

@ -738,36 +738,14 @@ virt-customize -q -a "${FILE}" --run-command "systemctl enable install-docker.se
# Try to install packages and Docker during image customization # Try to install packages and Docker during image customization
DOCKER_INSTALLED_ON_FIRST_BOOT="yes" # Assume first-boot by default DOCKER_INSTALLED_ON_FIRST_BOOT="yes" # Assume first-boot by default
# Start package installation in background with spinner msg_info "Installing base packages (qemu-guest-agent, curl, ca-certificates)"
echo -ne "${TAB}${YW}Installing base packages (qemu-guest-agent, curl, ca-certificates)..." if virt-customize -a "${FILE}" --install qemu-guest-agent,curl,ca-certificates >/dev/null 2>&1; then
virt-customize -a "${FILE}" --install qemu-guest-agent,curl,ca-certificates >/dev/null 2>&1 & msg_ok "Installed base packages"
INSTALL_PID=$!
# Simple progress dots instead of spinner (more reliable) msg_info "Installing Docker via get.docker.com"
while kill -0 $INSTALL_PID 2>/dev/null; do if virt-customize -q -a "${FILE}" --run-command "curl -fsSL https://get.docker.com | sh" >/dev/null 2>&1 &&
echo -ne "." virt-customize -q -a "${FILE}" --run-command "systemctl enable docker" >/dev/null 2>&1; then
sleep 1 msg_ok "Installed Docker"
done
wait $INSTALL_PID
INSTALL_EXIT=$?
if [ $INSTALL_EXIT -eq 0 ]; then
echo -e " ${GN}${CL}"
echo -ne "${TAB}${YW}Installing Docker via get.docker.com..."
virt-customize -q -a "${FILE}" --run-command "curl -fsSL https://get.docker.com | sh" >/dev/null 2>&1 &
DOCKER_PID=$!
while kill -0 $DOCKER_PID 2>/dev/null; do
echo -ne "."
sleep 1
done
wait $DOCKER_PID
DOCKER_EXIT=$?
if [ $DOCKER_EXIT -eq 0 ]; then
echo -e " ${GN}${CL}"
virt-customize -q -a "${FILE}" --run-command "systemctl enable docker" >/dev/null 2>&1
# Optimize Docker daemon configuration # Optimize Docker daemon configuration
virt-customize -q -a "${FILE}" --run-command "mkdir -p /etc/docker" >/dev/null 2>&1 virt-customize -q -a "${FILE}" --run-command "mkdir -p /etc/docker" >/dev/null 2>&1
@ -786,14 +764,11 @@ DOCKEREOF" >/dev/null 2>&1
virt-customize -q -a "${FILE}" --run-command "touch /root/.docker-installed" >/dev/null 2>&1 virt-customize -q -a "${FILE}" --run-command "touch /root/.docker-installed" >/dev/null 2>&1
DOCKER_INSTALLED_ON_FIRST_BOOT="no" DOCKER_INSTALLED_ON_FIRST_BOOT="no"
msg_ok "Docker and Docker Compose added to ${OS_DISPLAY} Qcow2 Disk Image successfully"
else else
echo -e " ${RD}${CL}" msg_ok "Docker will be installed on first boot (installation failed during image preparation)"
msg_ok "Using first-boot installation method (Docker installation failed during image customization)"
fi fi
else else
echo -e " ${RD}${CL}" msg_ok "Packages will be installed on first boot (network not available during image preparation)"
msg_ok "Using first-boot installation method (network not available during image customization)"
fi fi
# Set hostname and clean machine-id # Set hostname and clean machine-id