Add --setup-repo option to configure repositories without installing packages

The `--setup-repo` flag allows users to add Docker package repositories
to without automatically installing Docker packages.

This is useful for scenarios where users want to configure the
repository but handle package installation separately.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski committed 2025-09-18 13:55:29 +02:00
1 parent 30c930eeeb
commit 9b2cd0e08d
1 file changed
+23
+23
View File
@@ -75,6 +75,14 @@ set -e
#
# $ sudo sh install-docker.sh --mirror AzureChinaCloud
#
# --setup-repo
#
# Use the --setup-repo option to configure Docker's package repositories without
# installing Docker packages. This is useful when you want to add the repository
# but install packages separately:
#
# $ sudo sh install-docker.sh --setup-repo
#
# ==============================================================================
@@ -110,6 +118,7 @@ fi
mirror=''
DRY_RUN=${DRY_RUN:-}
REPO_ONLY=${REPO_ONLY:-0}
while [ $# -gt 0 ]; do
case "$1" in
--channel)
@@ -127,6 +136,10 @@ while [ $# -gt 0 ]; do
VERSION="${2#v}"
shift
;;
--setup-repo)
REPO_ONLY=1
shift
;;
--*)
echo "Illegal option $1"
;;
@@ -519,6 +532,11 @@ do_install() {
$sh_c "echo \"$apt_repo\" > /etc/apt/sources.list.d/docker.list"
$sh_c 'apt-get -qq update >/dev/null'
)
if [ "$REPO_ONLY" = "1" ]; then
exit 0
fi
pkg_version=""
if [ -n "$VERSION" ]; then
if is_dry_run; then
@@ -608,6 +626,11 @@ do_install() {
$sh_c "yum makecache"
fi
)
if [ "$REPO_ONLY" = "1" ]; then
exit 0
fi
pkg_version=""
if command_exists dnf; then
pkg_manager="dnf"