From 0482e55f863c10e491d9327184d3a2e71b3c0aea Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 26 Jan 2025 14:47:36 +0100 Subject: [PATCH] Docker containers should start at boottime. --- README.install-latest | 11 ++++++++- install-docker.sh | 55 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/README.install-latest b/README.install-latest index 0e8c0ad..6195597 100644 --- a/README.install-latest +++ b/README.install-latest @@ -60,8 +60,17 @@ apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docke # systemctl disable docker.service # systemctl disable containerd.service # -systemctl enable docker.service systemctl enable containerd.service +systemctl enable docker.service + +# !! Note !! +# +# if enabling 'docker service' failed, you can try to manually set the symlink that causes +# automatic booting: +# +# ln -s /lib/systemd/system/docker.service /etc/systemd/system/multi-user.target.wants/ + +systemctl daemon-reload # ---------- diff --git a/install-docker.sh b/install-docker.sh index 84a0b3e..3c380ee 100755 --- a/install-docker.sh +++ b/install-docker.sh @@ -538,5 +538,60 @@ else info "All needed debian packages already installed." fi + +_service_name="containerd" +echononl "Enable '${_service_name}.service' - start at boot time.." +if $(systemctl is-enabled ${_service_name}.service --quiet 2> /dev/null) ; then + echo_skipped +else + systemctl enable ${_service_name}.service > "$log_file" 2>&1 + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + fi +fi + + +_service_name="docker" +echononl "Enable '${_service_name}.service' - start at boot time.." +if $(systemctl is-enabled ${_service_name}.service --quiet 2> /dev/null) ; then + echo_skipped +else + systemctl enable ${_service_name}.service > "$log_file" 2>&1 + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + + info "You can try to manually set the symlink that causes automatic booting: + + \033[1mln -s /lib/systemd/system/docker.service /etc/systemd/system/multi-user.target.wants/\033[m" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + fi +fi + + clean_up 0