Files
ProxmoxVE/install/docker-install.sh
T
MickLesk 4267cdf15c Docker/NPMplus (Alpine): use docker-cli-compose instead of a downloaded binary
The Alpine installs put Compose into /root/.docker/cli-plugins by curl.
Nothing updated it afterwards (the update is apk -U upgrade), and the CLI
prefers that directory over the package path. Install docker-cli-compose
instead, and on update move existing containers to the package before
removing the old binary.
2026-12-03 09:57:16 +01:00

97 lines
2.8 KiB
Bash

#!/usr/bin/env bash
# Copyright (c) 2021-2026 tteck
# Author: tteck (tteckster)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.docker.com/
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
setup_deb_based() {
setup_docker
socket_choice="${var_docker_socket:-}"
[[ -n "$socket_choice" ]] || read -r -p "${TAB3}Expose Docker TCP socket (insecure) ? [n = No, l = Local only (127.0.0.1), a = All interfaces (0.0.0.0)] <n/l/a>: " socket_choice || true
case "${socket_choice,,}" in
l | local)
socket="tcp://127.0.0.1:2375"
;;
a | all)
socket="tcp://0.0.0.0:2375"
;;
*)
socket=""
;;
esac
if [[ -n "$socket" ]]; then
msg_info "Enabling Docker TCP socket on $socket"
$STD apt install -y jq
tmpfile=$(mktemp)
jq --arg sock "$socket" '. + { "hosts": ["unix:///var/run/docker.sock", $sock] }' /etc/docker/daemon.json >"$tmpfile" && mv "$tmpfile" /etc/docker/daemon.json
mkdir -p /etc/systemd/system/docker.service.d
cat <<EOF >/etc/systemd/system/docker.service.d/override.conf
[Service]
ExecStart=
ExecStart=$(command -v dockerd || echo /usr/sbin/dockerd)
EOF
$STD systemctl daemon-reexec
$STD systemctl daemon-reload
if systemctl restart docker; then
msg_ok "Docker TCP socket available on $socket"
else
msg_error "Docker failed to restart. Check journalctl -xeu docker.service"
exit 150
fi
fi
}
setup_alpine() {
msg_info "Installing Dependencies"
$STD apk add tzdata openssl
msg_ok "Installed Dependencies"
msg_info "Installing Docker"
$STD apk add docker
$STD rc-service docker start
$STD rc-update add docker default
msg_ok "Installed Docker"
prompt="${var_docker_compose:-}"
[[ -n "$prompt" ]] || read -r -p "${TAB3}Would you like to add Docker Compose? <y/N> " prompt || true
if [[ "${prompt,,}" =~ ^(y|yes|true)$ ]]; then
msg_info "Installing Docker Compose"
$STD apk add docker-cli-compose
msg_ok "Installed Docker Compose $(docker compose version --short)"
fi
prompt="${var_docker_socket:-}"
[[ -n "$prompt" ]] || read -r -p "${TAB3}Would you like to expose the Docker TCP socket? <y/N> " prompt || true
case "${prompt,,}" in
y | yes | a | all) socket="tcp://0.0.0.0:2375" ;;
l | local) socket="tcp://127.0.0.1:2375" ;;
*) socket="" ;;
esac
if [[ -n "$socket" ]]; then
msg_info "Exposing Docker TCP socket on $socket"
mkdir -p /etc/docker
# No $STD here: silent() captures stdout, which left daemon.json empty.
printf '{ "hosts": ["unix:///var/run/docker.sock", "%s"] }\n' "$socket" >/etc/docker/daemon.json
$STD rc-service docker restart
msg_ok "Exposed Docker TCP socket on $socket"
fi
}
run_os_setup
motd_ssh
customize
cleanup_lxc