dockerd-rootless-setuptool.sh: show more helpful error messages

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2020-11-20 04:39:14 +09:00
parent 6c0a036dce
commit ab09458e21
No known key found for this signature in database
GPG Key ID: 49524C6F9F638F1A
1 changed files with 20 additions and 2 deletions

View File

@ -269,6 +269,16 @@ cmd_entrypoint_check() {
INFO "Requirements are satisfied"
}
show_systemd_error() {
n="20"
ERROR "Failed to start ${SYSTEMD_UNIT}. Run \`journalctl -n ${n} --no-pager --user --unit ${SYSTEMD_UNIT}\` to show the error log."
ERROR "Before retrying installation, you might need to uninstall the current setup: \`$0 uninstall -f ; ${BIN}/rootlesskit rm -rf ${HOME}/.local/share/docker\`"
if journalctl -q -n ${n} --user --unit ${SYSTEMD_UNIT} | grep -qF "/run/xtables.lock: Permission denied"; then
ERROR "Failure likely related to https://github.com/moby/moby/issues/41230"
ERROR "This may work as a workaround: \`sudo dnf install -y policycoreutils-python-utils && sudo semanage permissive -a iptables_t\`"
fi
}
# install (systemd)
install_systemd() {
mkdir -p "${CFG_DIR}/systemd/user"
@ -307,13 +317,21 @@ install_systemd() {
INFO "starting systemd service ${SYSTEMD_UNIT}"
(
set -x
systemctl --user start "${SYSTEMD_UNIT}"
if ! systemctl --user start "${SYSTEMD_UNIT}"; then
set +x
show_systemd_error
exit 1
fi
sleep 3
)
fi
(
set -x
systemctl --user --no-pager --full status "${SYSTEMD_UNIT}"
if ! systemctl --user --no-pager --full status "${SYSTEMD_UNIT}"; then
set +x
show_systemd_error
exit 1
fi
DOCKER_HOST="unix://$XDG_RUNTIME_DIR/docker.sock" $BIN/docker version
systemctl --user enable "${SYSTEMD_UNIT}"
)