From 91bc5b3835fdd0349dbc5438825339832589bd55 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Sun, 11 Oct 2026 13:24:31 +0200 Subject: [PATCH] docker: take the lxcfs toggle, TCP socket and Compose choice from app variables (#17850) * docker: take the lxcfs toggle, TCP socket and Compose choice from app variables var_docker_lxcfs is exported for the core helper; var_docker_tcp_socket (no/local/all) and var_docker_compose replace the prompts when set, so the website generator can offer them. Alpine wrote daemon.json through silent(), which captured the output and left the file empty. * docker: use var_docker_socket, the name the catalog record already carries --- ct/docker.sh | 4 ++++ install/docker-install.sh | 40 ++++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/ct/docker.sh b/ct/docker.sh index 6e97d3dbc..a01805c18 100644 --- a/ct/docker.sh +++ b/ct/docker.sh @@ -27,6 +27,10 @@ else var_disk="${var_disk:-4}" var_version="${var_version:-13}" fi +# Only exported variables reach the install through lxc-attach. +export var_docker_socket="${var_docker_socket:-}" +export var_docker_compose="${var_docker_compose:-}" +export var_docker_lxcfs="${var_docker_lxcfs:-}" header_info "$APP" variables diff --git a/install/docker-install.sh b/install/docker-install.sh index d9196229f..9debc98ae 100644 --- a/install/docker-install.sh +++ b/install/docker-install.sh @@ -15,12 +15,16 @@ update_os setup_deb_based() { setup_docker - 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)] : " socket_choice + if [[ -n "${var_docker_socket:-}" ]]; then + socket_choice="$var_docker_socket" + else + 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)] : " socket_choice + fi case "${socket_choice,,}" in - l) + l | local) socket="tcp://127.0.0.1:2375" ;; - a) + a | all) socket="tcp://0.0.0.0:2375" ;; *) @@ -66,8 +70,12 @@ setup_alpine() { msg_ok "Installed Docker" DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_github_release "docker/compose" false) - read -r -p "${TAB3}Would you like to add Docker Compose? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + if [[ -n "${var_docker_compose:-}" ]]; then + prompt="$var_docker_compose" + else + read -r -p "${TAB3}Would you like to add Docker Compose? " prompt + fi + if [[ "${prompt,,}" =~ ^(y|yes|true)$ ]]; then msg_info "Installing Docker Compose $DOCKER_COMPOSE_LATEST_VERSION" DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} mkdir -p "$DOCKER_CONFIG"/cli-plugins @@ -75,13 +83,23 @@ setup_alpine() { chmod +x "$DOCKER_CONFIG"/cli-plugins/docker-compose msg_ok "Installed Docker Compose $DOCKER_COMPOSE_LATEST_VERSION" fi - read -r -p "${TAB3}Would you like to expose the Docker TCP socket? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - msg_info "Exposing Docker TCP socket" - $STD mkdir -p /etc/docker - $STD echo '{ "hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2375"] }' >/etc/docker/daemon.json + if [[ -n "${var_docker_socket:-}" ]]; then + prompt="$var_docker_socket" + else + read -r -p "${TAB3}Would you like to expose the Docker TCP socket? " prompt + fi + 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 at tcp://+:2375" + msg_ok "Exposed Docker TCP socket on $socket" fi }