@@ -75,6 +75,11 @@ set -e
7575#
7676# $ sudo sh install-docker.sh --mirror AzureChinaCloud
7777#
78+ # --no-gpg-mirror
79+ #
80+ # Use the --no-gpg-mirror to always download the GPG from download.docker.com.
81+ # This ensures that the GPG key is always downloaded from a trusted source.
82+ #
7883# ==============================================================================
7984
8085
105110
106111mirror=' '
107112DRY_RUN=${DRY_RUN:- }
113+ NO_GPG_MIRROR=${NO_GPG_MIRROR:- }
108114while [ $# -gt 0 ]; do
109115 case " $1 " in
110116 --channel)
@@ -114,6 +120,9 @@ while [ $# -gt 0 ]; do
114120 --dry-run)
115121 DRY_RUN=1
116122 ;;
123+ --no-gpg-mirror)
124+ NO_GPG_MIRROR=1
125+ ;;
117126 --mirror)
118127 mirror=" $2 "
119128 shift
@@ -129,6 +138,11 @@ while [ $# -gt 0 ]; do
129138 shift $(( $# > 0 ? 1 : 0 ))
130139done
131140
141+ GPG_KEY_URL=" $DOWNLOAD_URL /linux/$lsb_dist /gpg"
142+ if [ -n " $NO_GPG_MIRROR " ]; then
143+ GPG_KEY_URL=" https://download.docker.com/linux/$lsb_dist /gpg"
144+ fi
145+
132146case " $mirror " in
133147 Aliyun)
134148 DOWNLOAD_URL=" https://mirrors.aliyun.com/docker-ce"
@@ -501,7 +515,7 @@ do_install() {
501515 $sh_c ' apt-get -qq update >/dev/null'
502516 $sh_c " DEBIAN_FRONTEND=noninteractive apt-get -y -qq install $pre_reqs >/dev/null"
503517 $sh_c ' install -m 0755 -d /etc/apt/keyrings'
504- $sh_c " curl -fsSL \" $DOWNLOAD_URL /linux/ $lsb_dist /gpg \" -o /etc/apt/keyrings/docker.asc"
518+ $sh_c " curl -fsSL \" $GPG_KEY_URL \" -o /etc/apt/keyrings/docker.asc"
505519 $sh_c " chmod a+r /etc/apt/keyrings/docker.asc"
506520 $sh_c " echo \" $apt_repo \" > /etc/apt/sources.list.d/docker.list"
507521 $sh_c ' apt-get -qq update >/dev/null'
0 commit comments