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.
This commit is contained in:
MickLesk
2026-10-11 12:39:29 +02:00
parent 701268bff4
commit 31f28b9def
2 changed files with 33 additions and 11 deletions
+4
View File
@@ -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_tcp_socket="${var_docker_tcp_socket:-}"
export var_docker_compose="${var_docker_compose:-}"
export var_docker_lxcfs="${var_docker_lxcfs:-}"
header_info "$APP"
variables
+29 -11
View File
@@ -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)] <n/l/a>: " socket_choice
if [[ -n "${var_docker_tcp_socket:-}" ]]; then
socket_choice="$var_docker_tcp_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)] <n/l/a>: " 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? <y/N> " 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? <y/N> " 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? <y/N> " 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_tcp_socket:-}" ]]; then
prompt="$var_docker_tcp_socket"
else
read -r -p "${TAB3}Would you like to expose the Docker TCP socket? <y/N> " 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
}