mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #42109 from AkihiroSuda/rootless-add-context-2010
[20.10 backport] dockerd-rootless-setuptool.sh: create CLI context "rootless"
This commit is contained in:
commit
94854bcbd6
1 changed files with 31 additions and 0 deletions
|
@ -23,6 +23,7 @@ ERROR() {
|
||||||
# constants
|
# constants
|
||||||
DOCKERD_ROOTLESS_SH="dockerd-rootless.sh"
|
DOCKERD_ROOTLESS_SH="dockerd-rootless.sh"
|
||||||
SYSTEMD_UNIT="docker.service"
|
SYSTEMD_UNIT="docker.service"
|
||||||
|
CLI_CONTEXT="rootless"
|
||||||
|
|
||||||
# CLI opt: --force
|
# CLI opt: --force
|
||||||
OPT_FORCE=""
|
OPT_FORCE=""
|
||||||
|
@ -350,6 +351,23 @@ install_nonsystemd() {
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cli_ctx_exists() {
|
||||||
|
name="$1"
|
||||||
|
"${BIN}/docker" context inspect -f "{{.Name}}" "${name}" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
cli_ctx_create() {
|
||||||
|
name="$1"
|
||||||
|
host="$2"
|
||||||
|
description="$3"
|
||||||
|
"${BIN}/docker" context create "${name}" --docker "host=${host}" --description "${description}" > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
cli_ctx_rm() {
|
||||||
|
name="$1"
|
||||||
|
"${BIN}/docker" context rm -f "${name}" > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
# CLI subcommand: "install"
|
# CLI subcommand: "install"
|
||||||
cmd_entrypoint_install() {
|
cmd_entrypoint_install() {
|
||||||
# requirements are already checked in init()
|
# requirements are already checked in init()
|
||||||
|
@ -359,6 +377,14 @@ cmd_entrypoint_install() {
|
||||||
install_systemd
|
install_systemd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if cli_ctx_exists "${CLI_CONTEXT}"; then
|
||||||
|
INFO "CLI context \"${CLI_CONTEXT}\" already exists"
|
||||||
|
else
|
||||||
|
INFO "Creating CLI context \"${CLI_CONTEXT}\""
|
||||||
|
cli_ctx_create "${CLI_CONTEXT}" "unix://${XDG_RUNTIME_DIR}/docker.sock" "Rootless mode"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
INFO "Make sure the following environment variables are set (or add them to ~/.bashrc):"
|
INFO "Make sure the following environment variables are set (or add them to ~/.bashrc):"
|
||||||
echo
|
echo
|
||||||
if [ -n "$XDG_RUNTIME_DIR_CREATED" ]; then
|
if [ -n "$XDG_RUNTIME_DIR_CREATED" ]; then
|
||||||
|
@ -390,6 +416,11 @@ cmd_entrypoint_uninstall() {
|
||||||
INFO "Uninstalled ${SYSTEMD_UNIT}"
|
INFO "Uninstalled ${SYSTEMD_UNIT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if cli_ctx_exists "${CLI_CONTEXT}"; then
|
||||||
|
cli_ctx_rm "${CLI_CONTEXT}"
|
||||||
|
INFO "Deleted CLI context \"${CLI_CONTEXT}\""
|
||||||
|
fi
|
||||||
|
|
||||||
INFO "This uninstallation tool does NOT remove Docker binaries and data."
|
INFO "This uninstallation tool does NOT remove Docker binaries and data."
|
||||||
INFO "To remove data, run: \`$BIN/rootlesskit rm -rf $HOME/.local/share/docker\`"
|
INFO "To remove data, run: \`$BIN/rootlesskit rm -rf $HOME/.local/share/docker\`"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue