Noveramaaz
commited on
Commit
•
0683671
1
Parent(s):
0617bd2
Delete get-docker.sh
Browse files- get-docker.sh +0 -743
get-docker.sh
DELETED
@@ -1,743 +0,0 @@
|
|
1 |
-
#!/bin/sh
|
2 |
-
set -e
|
3 |
-
# Docker Engine for Linux installation script.
|
4 |
-
#
|
5 |
-
# This script is intended as a convenient way to configure docker's package
|
6 |
-
# repositories and to install Docker Engine, This script is not recommended
|
7 |
-
# for production environments. Before running this script, make yourself familiar
|
8 |
-
# with potential risks and limitations, and refer to the installation manual
|
9 |
-
# at https://docs.docker.com/engine/install/ for alternative installation methods.
|
10 |
-
#
|
11 |
-
# The script:
|
12 |
-
#
|
13 |
-
# - Requires `root` or `sudo` privileges to run.
|
14 |
-
# - Attempts to detect your Linux distribution and version and configure your
|
15 |
-
# package management system for you.
|
16 |
-
# - Doesn't allow you to customize most installation parameters.
|
17 |
-
# - Installs dependencies and recommendations without asking for confirmation.
|
18 |
-
# - Installs the latest stable release (by default) of Docker CLI, Docker Engine,
|
19 |
-
# Docker Buildx, Docker Compose, containerd, and runc. When using this script
|
20 |
-
# to provision a machine, this may result in unexpected major version upgrades
|
21 |
-
# of these packages. Always test upgrades in a test environment before
|
22 |
-
# deploying to your production systems.
|
23 |
-
# - Isn't designed to upgrade an existing Docker installation. When using the
|
24 |
-
# script to update an existing installation, dependencies may not be updated
|
25 |
-
# to the expected version, resulting in outdated versions.
|
26 |
-
#
|
27 |
-
# Source code is available at https://github.com/docker/docker-install/
|
28 |
-
#
|
29 |
-
# Usage
|
30 |
-
# ==============================================================================
|
31 |
-
#
|
32 |
-
# To install the latest stable versions of Docker CLI, Docker Engine, and their
|
33 |
-
# dependencies:
|
34 |
-
#
|
35 |
-
# 1. download the script
|
36 |
-
#
|
37 |
-
# $ curl -fsSL https://get.docker.com -o install-docker.sh
|
38 |
-
#
|
39 |
-
# 2. verify the script's content
|
40 |
-
#
|
41 |
-
# $ cat install-docker.sh
|
42 |
-
#
|
43 |
-
# 3. run the script with --dry-run to verify the steps it executes
|
44 |
-
#
|
45 |
-
# $ sh install-docker.sh --dry-run
|
46 |
-
#
|
47 |
-
# 4. run the script either as root, or using sudo to perform the installation.
|
48 |
-
#
|
49 |
-
# $ sudo sh install-docker.sh
|
50 |
-
#
|
51 |
-
# Command-line options
|
52 |
-
# ==============================================================================
|
53 |
-
#
|
54 |
-
# --version <VERSION>
|
55 |
-
# Use the --version option to install a specific version, for example:
|
56 |
-
#
|
57 |
-
# $ sudo sh install-docker.sh --version 23.0
|
58 |
-
#
|
59 |
-
# --channel <stable|test>
|
60 |
-
#
|
61 |
-
# Use the --channel option to install from an alternative installation channel.
|
62 |
-
# The following example installs the latest versions from the "test" channel,
|
63 |
-
# which includes pre-releases (alpha, beta, rc):
|
64 |
-
#
|
65 |
-
# $ sudo sh install-docker.sh --channel test
|
66 |
-
#
|
67 |
-
# Alternatively, use the script at https://test.docker.com, which uses the test
|
68 |
-
# channel as default.
|
69 |
-
#
|
70 |
-
# --mirror <Aliyun|AzureChinaCloud>
|
71 |
-
#
|
72 |
-
# Use the --mirror option to install from a mirror supported by this script.
|
73 |
-
# Available mirrors are "Aliyun" (https://mirrors.aliyun.com/docker-ce), and
|
74 |
-
# "AzureChinaCloud" (https://mirror.azure.cn/docker-ce), for example:
|
75 |
-
#
|
76 |
-
# $ sudo sh install-docker.sh --mirror AzureChinaCloud
|
77 |
-
#
|
78 |
-
# ==============================================================================
|
79 |
-
|
80 |
-
|
81 |
-
# Git commit from https://github.com/docker/docker-install when
|
82 |
-
# the script was uploaded (Should only be modified by upload job):
|
83 |
-
SCRIPT_COMMIT_SHA="e5543d473431b782227f8908005543bb4389b8de"
|
84 |
-
|
85 |
-
# strip "v" prefix if present
|
86 |
-
VERSION="${VERSION#v}"
|
87 |
-
|
88 |
-
# The channel to install from:
|
89 |
-
# * stable
|
90 |
-
# * test
|
91 |
-
# * edge (deprecated)
|
92 |
-
# * nightly (deprecated)
|
93 |
-
DEFAULT_CHANNEL_VALUE="stable"
|
94 |
-
if [ -z "$CHANNEL" ]; then
|
95 |
-
CHANNEL=$DEFAULT_CHANNEL_VALUE
|
96 |
-
fi
|
97 |
-
|
98 |
-
DEFAULT_DOWNLOAD_URL="https://download.docker.com"
|
99 |
-
if [ -z "$DOWNLOAD_URL" ]; then
|
100 |
-
DOWNLOAD_URL=$DEFAULT_DOWNLOAD_URL
|
101 |
-
fi
|
102 |
-
|
103 |
-
DEFAULT_REPO_FILE="docker-ce.repo"
|
104 |
-
if [ -z "$REPO_FILE" ]; then
|
105 |
-
REPO_FILE="$DEFAULT_REPO_FILE"
|
106 |
-
fi
|
107 |
-
|
108 |
-
mirror=''
|
109 |
-
DRY_RUN=${DRY_RUN:-}
|
110 |
-
while [ $# -gt 0 ]; do
|
111 |
-
case "$1" in
|
112 |
-
--channel)
|
113 |
-
CHANNEL="$2"
|
114 |
-
shift
|
115 |
-
;;
|
116 |
-
--dry-run)
|
117 |
-
DRY_RUN=1
|
118 |
-
;;
|
119 |
-
--mirror)
|
120 |
-
mirror="$2"
|
121 |
-
shift
|
122 |
-
;;
|
123 |
-
--version)
|
124 |
-
VERSION="${2#v}"
|
125 |
-
shift
|
126 |
-
;;
|
127 |
-
--*)
|
128 |
-
echo "Illegal option $1"
|
129 |
-
;;
|
130 |
-
esac
|
131 |
-
shift $(( $# > 0 ? 1 : 0 ))
|
132 |
-
done
|
133 |
-
|
134 |
-
case "$mirror" in
|
135 |
-
Aliyun)
|
136 |
-
DOWNLOAD_URL="https://mirrors.aliyun.com/docker-ce"
|
137 |
-
;;
|
138 |
-
AzureChinaCloud)
|
139 |
-
DOWNLOAD_URL="https://mirror.azure.cn/docker-ce"
|
140 |
-
;;
|
141 |
-
"")
|
142 |
-
;;
|
143 |
-
*)
|
144 |
-
>&2 echo "unknown mirror '$mirror': use either 'Aliyun', or 'AzureChinaCloud'."
|
145 |
-
exit 1
|
146 |
-
;;
|
147 |
-
esac
|
148 |
-
|
149 |
-
case "$CHANNEL" in
|
150 |
-
stable|test)
|
151 |
-
;;
|
152 |
-
edge|nightly)
|
153 |
-
>&2 echo "DEPRECATED: the $CHANNEL channel has been deprecated and is no longer supported by this script."
|
154 |
-
exit 1
|
155 |
-
;;
|
156 |
-
*)
|
157 |
-
>&2 echo "unknown CHANNEL '$CHANNEL': use either stable or test."
|
158 |
-
exit 1
|
159 |
-
;;
|
160 |
-
esac
|
161 |
-
|
162 |
-
command_exists() {
|
163 |
-
command -v "$@" > /dev/null 2>&1
|
164 |
-
}
|
165 |
-
|
166 |
-
# version_gte checks if the version specified in $VERSION is at least the given
|
167 |
-
# SemVer (Maj.Minor[.Patch]), or CalVer (YY.MM) version.It returns 0 (success)
|
168 |
-
# if $VERSION is either unset (=latest) or newer or equal than the specified
|
169 |
-
# version, or returns 1 (fail) otherwise.
|
170 |
-
#
|
171 |
-
# examples:
|
172 |
-
#
|
173 |
-
# VERSION=23.0
|
174 |
-
# version_gte 23.0 // 0 (success)
|
175 |
-
# version_gte 20.10 // 0 (success)
|
176 |
-
# version_gte 19.03 // 0 (success)
|
177 |
-
# version_gte 21.10 // 1 (fail)
|
178 |
-
version_gte() {
|
179 |
-
if [ -z "$VERSION" ]; then
|
180 |
-
return 0
|
181 |
-
fi
|
182 |
-
eval version_compare "$VERSION" "$1"
|
183 |
-
}
|
184 |
-
|
185 |
-
# version_compare compares two version strings (either SemVer (Major.Minor.Path),
|
186 |
-
# or CalVer (YY.MM) version strings. It returns 0 (success) if version A is newer
|
187 |
-
# or equal than version B, or 1 (fail) otherwise. Patch releases and pre-release
|
188 |
-
# (-alpha/-beta) are not taken into account
|
189 |
-
#
|
190 |
-
# examples:
|
191 |
-
#
|
192 |
-
# version_compare 23.0.0 20.10 // 0 (success)
|
193 |
-
# version_compare 23.0 20.10 // 0 (success)
|
194 |
-
# version_compare 20.10 19.03 // 0 (success)
|
195 |
-
# version_compare 20.10 20.10 // 0 (success)
|
196 |
-
# version_compare 19.03 20.10 // 1 (fail)
|
197 |
-
version_compare() (
|
198 |
-
set +x
|
199 |
-
|
200 |
-
yy_a="$(echo "$1" | cut -d'.' -f1)"
|
201 |
-
yy_b="$(echo "$2" | cut -d'.' -f1)"
|
202 |
-
if [ "$yy_a" -lt "$yy_b" ]; then
|
203 |
-
return 1
|
204 |
-
fi
|
205 |
-
if [ "$yy_a" -gt "$yy_b" ]; then
|
206 |
-
return 0
|
207 |
-
fi
|
208 |
-
mm_a="$(echo "$1" | cut -d'.' -f2)"
|
209 |
-
mm_b="$(echo "$2" | cut -d'.' -f2)"
|
210 |
-
|
211 |
-
# trim leading zeros to accommodate CalVer
|
212 |
-
mm_a="${mm_a#0}"
|
213 |
-
mm_b="${mm_b#0}"
|
214 |
-
|
215 |
-
if [ "${mm_a:-0}" -lt "${mm_b:-0}" ]; then
|
216 |
-
return 1
|
217 |
-
fi
|
218 |
-
|
219 |
-
return 0
|
220 |
-
)
|
221 |
-
|
222 |
-
is_dry_run() {
|
223 |
-
if [ -z "$DRY_RUN" ]; then
|
224 |
-
return 1
|
225 |
-
else
|
226 |
-
return 0
|
227 |
-
fi
|
228 |
-
}
|
229 |
-
|
230 |
-
is_wsl() {
|
231 |
-
case "$(uname -r)" in
|
232 |
-
*microsoft* ) true ;; # WSL 2
|
233 |
-
*Microsoft* ) true ;; # WSL 1
|
234 |
-
* ) false;;
|
235 |
-
esac
|
236 |
-
}
|
237 |
-
|
238 |
-
is_darwin() {
|
239 |
-
case "$(uname -s)" in
|
240 |
-
*darwin* ) true ;;
|
241 |
-
*Darwin* ) true ;;
|
242 |
-
* ) false;;
|
243 |
-
esac
|
244 |
-
}
|
245 |
-
|
246 |
-
deprecation_notice() {
|
247 |
-
distro=$1
|
248 |
-
distro_version=$2
|
249 |
-
echo
|
250 |
-
printf "\033[91;1mDEPRECATION WARNING\033[0m\n"
|
251 |
-
printf " This Linux distribution (\033[1m%s %s\033[0m) reached end-of-life and is no longer supported by this script.\n" "$distro" "$distro_version"
|
252 |
-
echo " No updates or security fixes will be released for this distribution, and users are recommended"
|
253 |
-
echo " to upgrade to a currently maintained version of $distro."
|
254 |
-
echo
|
255 |
-
printf "Press \033[1mCtrl+C\033[0m now to abort this script, or wait for the installation to continue."
|
256 |
-
echo
|
257 |
-
sleep 10
|
258 |
-
}
|
259 |
-
|
260 |
-
get_distribution() {
|
261 |
-
lsb_dist=""
|
262 |
-
# Every system that we officially support has /etc/os-release
|
263 |
-
if [ -r /etc/os-release ]; then
|
264 |
-
lsb_dist="$(. /etc/os-release && echo "$ID")"
|
265 |
-
fi
|
266 |
-
# Returning an empty string here should be alright since the
|
267 |
-
# case statements don't act unless you provide an actual value
|
268 |
-
echo "$lsb_dist"
|
269 |
-
}
|
270 |
-
|
271 |
-
echo_docker_as_nonroot() {
|
272 |
-
if is_dry_run; then
|
273 |
-
return
|
274 |
-
fi
|
275 |
-
if command_exists docker && [ -e /var/run/docker.sock ]; then
|
276 |
-
(
|
277 |
-
set -x
|
278 |
-
$sh_c 'docker version'
|
279 |
-
) || true
|
280 |
-
fi
|
281 |
-
|
282 |
-
# intentionally mixed spaces and tabs here -- tabs are stripped by "<<-EOF", spaces are kept in the output
|
283 |
-
echo
|
284 |
-
echo "================================================================================"
|
285 |
-
echo
|
286 |
-
if version_gte "20.10"; then
|
287 |
-
echo "To run Docker as a non-privileged user, consider setting up the"
|
288 |
-
echo "Docker daemon in rootless mode for your user:"
|
289 |
-
echo
|
290 |
-
echo " dockerd-rootless-setuptool.sh install"
|
291 |
-
echo
|
292 |
-
echo "Visit https://docs.docker.com/go/rootless/ to learn about rootless mode."
|
293 |
-
echo
|
294 |
-
fi
|
295 |
-
echo
|
296 |
-
echo "To run the Docker daemon as a fully privileged service, but granting non-root"
|
297 |
-
echo "users access, refer to https://docs.docker.com/go/daemon-access/"
|
298 |
-
echo
|
299 |
-
echo "WARNING: Access to the remote API on a privileged Docker daemon is equivalent"
|
300 |
-
echo " to root access on the host. Refer to the 'Docker daemon attack surface'"
|
301 |
-
echo " documentation for details: https://docs.docker.com/go/attack-surface/"
|
302 |
-
echo
|
303 |
-
echo "================================================================================"
|
304 |
-
echo
|
305 |
-
}
|
306 |
-
|
307 |
-
# Check if this is a forked Linux distro
|
308 |
-
check_forked() {
|
309 |
-
|
310 |
-
# Check for lsb_release command existence, it usually exists in forked distros
|
311 |
-
if command_exists lsb_release; then
|
312 |
-
# Check if the `-u` option is supported
|
313 |
-
set +e
|
314 |
-
lsb_release -a -u > /dev/null 2>&1
|
315 |
-
lsb_release_exit_code=$?
|
316 |
-
set -e
|
317 |
-
|
318 |
-
# Check if the command has exited successfully, it means we're in a forked distro
|
319 |
-
if [ "$lsb_release_exit_code" = "0" ]; then
|
320 |
-
# Print info about current distro
|
321 |
-
cat <<-EOF
|
322 |
-
You're using '$lsb_dist' version '$dist_version'.
|
323 |
-
EOF
|
324 |
-
|
325 |
-
# Get the upstream release info
|
326 |
-
lsb_dist=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'id' | cut -d ':' -f 2 | tr -d '[:space:]')
|
327 |
-
dist_version=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'codename' | cut -d ':' -f 2 | tr -d '[:space:]')
|
328 |
-
|
329 |
-
# Print info about upstream distro
|
330 |
-
cat <<-EOF
|
331 |
-
Upstream release is '$lsb_dist' version '$dist_version'.
|
332 |
-
EOF
|
333 |
-
else
|
334 |
-
if [ -r /etc/debian_version ] && [ "$lsb_dist" != "ubuntu" ] && [ "$lsb_dist" != "raspbian" ]; then
|
335 |
-
if [ "$lsb_dist" = "osmc" ]; then
|
336 |
-
# OSMC runs Raspbian
|
337 |
-
lsb_dist=raspbian
|
338 |
-
else
|
339 |
-
# We're Debian and don't even know it!
|
340 |
-
lsb_dist=debian
|
341 |
-
fi
|
342 |
-
dist_version="$(sed 's/\/.*//' /etc/debian_version | sed 's/\..*//')"
|
343 |
-
case "$dist_version" in
|
344 |
-
12)
|
345 |
-
dist_version="bookworm"
|
346 |
-
;;
|
347 |
-
11)
|
348 |
-
dist_version="bullseye"
|
349 |
-
;;
|
350 |
-
10)
|
351 |
-
dist_version="buster"
|
352 |
-
;;
|
353 |
-
9)
|
354 |
-
dist_version="stretch"
|
355 |
-
;;
|
356 |
-
8)
|
357 |
-
dist_version="jessie"
|
358 |
-
;;
|
359 |
-
esac
|
360 |
-
fi
|
361 |
-
fi
|
362 |
-
fi
|
363 |
-
}
|
364 |
-
|
365 |
-
do_install() {
|
366 |
-
echo "# Executing docker install script, commit: $SCRIPT_COMMIT_SHA"
|
367 |
-
|
368 |
-
if command_exists docker; then
|
369 |
-
cat >&2 <<-'EOF'
|
370 |
-
Warning: the "docker" command appears to already exist on this system.
|
371 |
-
|
372 |
-
If you already have Docker installed, this script can cause trouble, which is
|
373 |
-
why we're displaying this warning and provide the opportunity to cancel the
|
374 |
-
installation.
|
375 |
-
|
376 |
-
If you installed the current Docker package using this script and are using it
|
377 |
-
again to update Docker, you can safely ignore this message.
|
378 |
-
|
379 |
-
You may press Ctrl+C now to abort this script.
|
380 |
-
EOF
|
381 |
-
( set -x; sleep 20 )
|
382 |
-
fi
|
383 |
-
|
384 |
-
user="$(id -un 2>/dev/null || true)"
|
385 |
-
|
386 |
-
sh_c='sh -c'
|
387 |
-
if [ "$user" != 'root' ]; then
|
388 |
-
if command_exists sudo; then
|
389 |
-
sh_c='sudo -E sh -c'
|
390 |
-
elif command_exists su; then
|
391 |
-
sh_c='su -c'
|
392 |
-
else
|
393 |
-
cat >&2 <<-'EOF'
|
394 |
-
Error: this installer needs the ability to run commands as root.
|
395 |
-
We are unable to find either "sudo" or "su" available to make this happen.
|
396 |
-
EOF
|
397 |
-
exit 1
|
398 |
-
fi
|
399 |
-
fi
|
400 |
-
|
401 |
-
if is_dry_run; then
|
402 |
-
sh_c="echo"
|
403 |
-
fi
|
404 |
-
|
405 |
-
# perform some very rudimentary platform detection
|
406 |
-
lsb_dist=$( get_distribution )
|
407 |
-
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
|
408 |
-
|
409 |
-
if is_wsl; then
|
410 |
-
echo
|
411 |
-
echo "WSL DETECTED: We recommend using Docker Desktop for Windows."
|
412 |
-
echo "Please get Docker Desktop from https://www.docker.com/products/docker-desktop/"
|
413 |
-
echo
|
414 |
-
cat >&2 <<-'EOF'
|
415 |
-
|
416 |
-
You may press Ctrl+C now to abort this script.
|
417 |
-
EOF
|
418 |
-
( set -x; sleep 20 )
|
419 |
-
fi
|
420 |
-
|
421 |
-
case "$lsb_dist" in
|
422 |
-
|
423 |
-
ubuntu)
|
424 |
-
if command_exists lsb_release; then
|
425 |
-
dist_version="$(lsb_release --codename | cut -f2)"
|
426 |
-
fi
|
427 |
-
if [ -z "$dist_version" ] && [ -r /etc/lsb-release ]; then
|
428 |
-
dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")"
|
429 |
-
fi
|
430 |
-
;;
|
431 |
-
|
432 |
-
debian|raspbian)
|
433 |
-
dist_version="$(sed 's/\/.*//' /etc/debian_version | sed 's/\..*//')"
|
434 |
-
case "$dist_version" in
|
435 |
-
12)
|
436 |
-
dist_version="bookworm"
|
437 |
-
;;
|
438 |
-
11)
|
439 |
-
dist_version="bullseye"
|
440 |
-
;;
|
441 |
-
10)
|
442 |
-
dist_version="buster"
|
443 |
-
;;
|
444 |
-
9)
|
445 |
-
dist_version="stretch"
|
446 |
-
;;
|
447 |
-
8)
|
448 |
-
dist_version="jessie"
|
449 |
-
;;
|
450 |
-
esac
|
451 |
-
;;
|
452 |
-
|
453 |
-
centos|rhel|sles)
|
454 |
-
if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
|
455 |
-
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
|
456 |
-
fi
|
457 |
-
;;
|
458 |
-
|
459 |
-
*)
|
460 |
-
if command_exists lsb_release; then
|
461 |
-
dist_version="$(lsb_release --release | cut -f2)"
|
462 |
-
fi
|
463 |
-
if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
|
464 |
-
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
|
465 |
-
fi
|
466 |
-
;;
|
467 |
-
|
468 |
-
esac
|
469 |
-
|
470 |
-
# Check if this is a forked Linux distro
|
471 |
-
check_forked
|
472 |
-
|
473 |
-
# Print deprecation warnings for distro versions that recently reached EOL,
|
474 |
-
# but may still be commonly used (especially LTS versions).
|
475 |
-
case "$lsb_dist.$dist_version" in
|
476 |
-
debian.stretch|debian.jessie)
|
477 |
-
deprecation_notice "$lsb_dist" "$dist_version"
|
478 |
-
;;
|
479 |
-
raspbian.stretch|raspbian.jessie)
|
480 |
-
deprecation_notice "$lsb_dist" "$dist_version"
|
481 |
-
;;
|
482 |
-
ubuntu.xenial|ubuntu.trusty)
|
483 |
-
deprecation_notice "$lsb_dist" "$dist_version"
|
484 |
-
;;
|
485 |
-
ubuntu.impish|ubuntu.hirsute|ubuntu.groovy|ubuntu.eoan|ubuntu.disco|ubuntu.cosmic)
|
486 |
-
deprecation_notice "$lsb_dist" "$dist_version"
|
487 |
-
;;
|
488 |
-
fedora.*)
|
489 |
-
if [ "$dist_version" -lt 36 ]; then
|
490 |
-
deprecation_notice "$lsb_dist" "$dist_version"
|
491 |
-
fi
|
492 |
-
;;
|
493 |
-
esac
|
494 |
-
|
495 |
-
# Run setup for each distro accordingly
|
496 |
-
case "$lsb_dist" in
|
497 |
-
ubuntu|debian|raspbian)
|
498 |
-
pre_reqs="apt-transport-https ca-certificates curl"
|
499 |
-
if ! command -v gpg > /dev/null; then
|
500 |
-
pre_reqs="$pre_reqs gnupg"
|
501 |
-
fi
|
502 |
-
apt_repo="deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] $DOWNLOAD_URL/linux/$lsb_dist $dist_version $CHANNEL"
|
503 |
-
(
|
504 |
-
if ! is_dry_run; then
|
505 |
-
set -x
|
506 |
-
fi
|
507 |
-
$sh_c 'apt-get update -qq >/dev/null'
|
508 |
-
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $pre_reqs >/dev/null"
|
509 |
-
$sh_c 'install -m 0755 -d /etc/apt/keyrings'
|
510 |
-
$sh_c "curl -fsSL \"$DOWNLOAD_URL/linux/$lsb_dist/gpg\" | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg"
|
511 |
-
$sh_c "chmod a+r /etc/apt/keyrings/docker.gpg"
|
512 |
-
$sh_c "echo \"$apt_repo\" > /etc/apt/sources.list.d/docker.list"
|
513 |
-
$sh_c 'apt-get update -qq >/dev/null'
|
514 |
-
)
|
515 |
-
pkg_version=""
|
516 |
-
if [ -n "$VERSION" ]; then
|
517 |
-
if is_dry_run; then
|
518 |
-
echo "# WARNING: VERSION pinning is not supported in DRY_RUN"
|
519 |
-
else
|
520 |
-
# Will work for incomplete versions IE (17.12), but may not actually grab the "latest" if in the test channel
|
521 |
-
pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/~ce~.*/g' | sed 's/-/.*/g')"
|
522 |
-
search_command="apt-cache madison docker-ce | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3"
|
523 |
-
pkg_version="$($sh_c "$search_command")"
|
524 |
-
echo "INFO: Searching repository for VERSION '$VERSION'"
|
525 |
-
echo "INFO: $search_command"
|
526 |
-
if [ -z "$pkg_version" ]; then
|
527 |
-
echo
|
528 |
-
echo "ERROR: '$VERSION' not found amongst apt-cache madison results"
|
529 |
-
echo
|
530 |
-
exit 1
|
531 |
-
fi
|
532 |
-
if version_gte "18.09"; then
|
533 |
-
search_command="apt-cache madison docker-ce-cli | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3"
|
534 |
-
echo "INFO: $search_command"
|
535 |
-
cli_pkg_version="=$($sh_c "$search_command")"
|
536 |
-
fi
|
537 |
-
pkg_version="=$pkg_version"
|
538 |
-
fi
|
539 |
-
fi
|
540 |
-
(
|
541 |
-
pkgs="docker-ce${pkg_version%=}"
|
542 |
-
if version_gte "18.09"; then
|
543 |
-
# older versions didn't ship the cli and containerd as separate packages
|
544 |
-
pkgs="$pkgs docker-ce-cli${cli_pkg_version%=} containerd.io"
|
545 |
-
fi
|
546 |
-
if version_gte "20.10"; then
|
547 |
-
pkgs="$pkgs docker-compose-plugin docker-ce-rootless-extras$pkg_version"
|
548 |
-
fi
|
549 |
-
if version_gte "23.0"; then
|
550 |
-
pkgs="$pkgs docker-buildx-plugin"
|
551 |
-
fi
|
552 |
-
if ! is_dry_run; then
|
553 |
-
set -x
|
554 |
-
fi
|
555 |
-
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $pkgs >/dev/null"
|
556 |
-
)
|
557 |
-
echo_docker_as_nonroot
|
558 |
-
exit 0
|
559 |
-
;;
|
560 |
-
centos|fedora|rhel)
|
561 |
-
if [ "$(uname -m)" != "s390x" ] && [ "$lsb_dist" = "rhel" ]; then
|
562 |
-
echo "Packages for RHEL are currently only available for s390x."
|
563 |
-
exit 1
|
564 |
-
fi
|
565 |
-
if [ "$lsb_dist" = "fedora" ]; then
|
566 |
-
pkg_manager="dnf"
|
567 |
-
config_manager="dnf config-manager"
|
568 |
-
enable_channel_flag="--set-enabled"
|
569 |
-
disable_channel_flag="--set-disabled"
|
570 |
-
pre_reqs="dnf-plugins-core"
|
571 |
-
pkg_suffix="fc$dist_version"
|
572 |
-
else
|
573 |
-
pkg_manager="yum"
|
574 |
-
config_manager="yum-config-manager"
|
575 |
-
enable_channel_flag="--enable"
|
576 |
-
disable_channel_flag="--disable"
|
577 |
-
pre_reqs="yum-utils"
|
578 |
-
pkg_suffix="el"
|
579 |
-
fi
|
580 |
-
repo_file_url="$DOWNLOAD_URL/linux/$lsb_dist/$REPO_FILE"
|
581 |
-
(
|
582 |
-
if ! is_dry_run; then
|
583 |
-
set -x
|
584 |
-
fi
|
585 |
-
$sh_c "$pkg_manager install -y -q $pre_reqs"
|
586 |
-
$sh_c "$config_manager --add-repo $repo_file_url"
|
587 |
-
|
588 |
-
if [ "$CHANNEL" != "stable" ]; then
|
589 |
-
$sh_c "$config_manager $disable_channel_flag 'docker-ce-*'"
|
590 |
-
$sh_c "$config_manager $enable_channel_flag 'docker-ce-$CHANNEL'"
|
591 |
-
fi
|
592 |
-
$sh_c "$pkg_manager makecache"
|
593 |
-
)
|
594 |
-
pkg_version=""
|
595 |
-
if [ -n "$VERSION" ]; then
|
596 |
-
if is_dry_run; then
|
597 |
-
echo "# WARNING: VERSION pinning is not supported in DRY_RUN"
|
598 |
-
else
|
599 |
-
pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/\\\\.ce.*/g' | sed 's/-/.*/g').*$pkg_suffix"
|
600 |
-
search_command="$pkg_manager list --showduplicates docker-ce | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'"
|
601 |
-
pkg_version="$($sh_c "$search_command")"
|
602 |
-
echo "INFO: Searching repository for VERSION '$VERSION'"
|
603 |
-
echo "INFO: $search_command"
|
604 |
-
if [ -z "$pkg_version" ]; then
|
605 |
-
echo
|
606 |
-
echo "ERROR: '$VERSION' not found amongst $pkg_manager list results"
|
607 |
-
echo
|
608 |
-
exit 1
|
609 |
-
fi
|
610 |
-
if version_gte "18.09"; then
|
611 |
-
# older versions don't support a cli package
|
612 |
-
search_command="$pkg_manager list --showduplicates docker-ce-cli | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'"
|
613 |
-
cli_pkg_version="$($sh_c "$search_command" | cut -d':' -f 2)"
|
614 |
-
fi
|
615 |
-
# Cut out the epoch and prefix with a '-'
|
616 |
-
pkg_version="-$(echo "$pkg_version" | cut -d':' -f 2)"
|
617 |
-
fi
|
618 |
-
fi
|
619 |
-
(
|
620 |
-
pkgs="docker-ce$pkg_version"
|
621 |
-
if version_gte "18.09"; then
|
622 |
-
# older versions didn't ship the cli and containerd as separate packages
|
623 |
-
if [ -n "$cli_pkg_version" ]; then
|
624 |
-
pkgs="$pkgs docker-ce-cli-$cli_pkg_version containerd.io"
|
625 |
-
else
|
626 |
-
pkgs="$pkgs docker-ce-cli containerd.io"
|
627 |
-
fi
|
628 |
-
fi
|
629 |
-
if version_gte "20.10"; then
|
630 |
-
pkgs="$pkgs docker-compose-plugin docker-ce-rootless-extras$pkg_version"
|
631 |
-
fi
|
632 |
-
if version_gte "23.0"; then
|
633 |
-
pkgs="$pkgs docker-buildx-plugin"
|
634 |
-
fi
|
635 |
-
if ! is_dry_run; then
|
636 |
-
set -x
|
637 |
-
fi
|
638 |
-
$sh_c "$pkg_manager install -y -q $pkgs"
|
639 |
-
)
|
640 |
-
echo_docker_as_nonroot
|
641 |
-
exit 0
|
642 |
-
;;
|
643 |
-
sles)
|
644 |
-
if [ "$(uname -m)" != "s390x" ]; then
|
645 |
-
echo "Packages for SLES are currently only available for s390x"
|
646 |
-
exit 1
|
647 |
-
fi
|
648 |
-
if [ "$dist_version" = "15.3" ]; then
|
649 |
-
sles_version="SLE_15_SP3"
|
650 |
-
else
|
651 |
-
sles_minor_version="${dist_version##*.}"
|
652 |
-
sles_version="15.$sles_minor_version"
|
653 |
-
fi
|
654 |
-
repo_file_url="$DOWNLOAD_URL/linux/$lsb_dist/$REPO_FILE"
|
655 |
-
pre_reqs="ca-certificates curl libseccomp2 awk"
|
656 |
-
(
|
657 |
-
if ! is_dry_run; then
|
658 |
-
set -x
|
659 |
-
fi
|
660 |
-
$sh_c "zypper install -y $pre_reqs"
|
661 |
-
$sh_c "zypper addrepo $repo_file_url"
|
662 |
-
if ! is_dry_run; then
|
663 |
-
cat >&2 <<-'EOF'
|
664 |
-
WARNING!!
|
665 |
-
openSUSE repository (https://download.opensuse.org/repositories/security:SELinux) will be enabled now.
|
666 |
-
Do you wish to continue?
|
667 |
-
You may press Ctrl+C now to abort this script.
|
668 |
-
EOF
|
669 |
-
( set -x; sleep 30 )
|
670 |
-
fi
|
671 |
-
opensuse_repo="https://download.opensuse.org/repositories/security:SELinux/$sles_version/security:SELinux.repo"
|
672 |
-
$sh_c "zypper addrepo $opensuse_repo"
|
673 |
-
$sh_c "zypper --gpg-auto-import-keys refresh"
|
674 |
-
$sh_c "zypper lr -d"
|
675 |
-
)
|
676 |
-
pkg_version=""
|
677 |
-
if [ -n "$VERSION" ]; then
|
678 |
-
if is_dry_run; then
|
679 |
-
echo "# WARNING: VERSION pinning is not supported in DRY_RUN"
|
680 |
-
else
|
681 |
-
pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/\\\\.ce.*/g' | sed 's/-/.*/g')"
|
682 |
-
search_command="zypper search -s --match-exact 'docker-ce' | grep '$pkg_pattern' | tail -1 | awk '{print \$6}'"
|
683 |
-
pkg_version="$($sh_c "$search_command")"
|
684 |
-
echo "INFO: Searching repository for VERSION '$VERSION'"
|
685 |
-
echo "INFO: $search_command"
|
686 |
-
if [ -z "$pkg_version" ]; then
|
687 |
-
echo
|
688 |
-
echo "ERROR: '$VERSION' not found amongst zypper list results"
|
689 |
-
echo
|
690 |
-
exit 1
|
691 |
-
fi
|
692 |
-
search_command="zypper search -s --match-exact 'docker-ce-cli' | grep '$pkg_pattern' | tail -1 | awk '{print \$6}'"
|
693 |
-
# It's okay for cli_pkg_version to be blank, since older versions don't support a cli package
|
694 |
-
cli_pkg_version="$($sh_c "$search_command")"
|
695 |
-
pkg_version="-$pkg_version"
|
696 |
-
fi
|
697 |
-
fi
|
698 |
-
(
|
699 |
-
pkgs="docker-ce$pkg_version"
|
700 |
-
if version_gte "18.09"; then
|
701 |
-
if [ -n "$cli_pkg_version" ]; then
|
702 |
-
# older versions didn't ship the cli and containerd as separate packages
|
703 |
-
pkgs="$pkgs docker-ce-cli-$cli_pkg_version containerd.io"
|
704 |
-
else
|
705 |
-
pkgs="$pkgs docker-ce-cli containerd.io"
|
706 |
-
fi
|
707 |
-
fi
|
708 |
-
if version_gte "20.10"; then
|
709 |
-
pkgs="$pkgs docker-compose-plugin docker-ce-rootless-extras$pkg_version"
|
710 |
-
fi
|
711 |
-
if version_gte "23.0"; then
|
712 |
-
pkgs="$pkgs docker-buildx-plugin"
|
713 |
-
fi
|
714 |
-
if ! is_dry_run; then
|
715 |
-
set -x
|
716 |
-
fi
|
717 |
-
$sh_c "zypper -q install -y $pkgs"
|
718 |
-
)
|
719 |
-
echo_docker_as_nonroot
|
720 |
-
exit 0
|
721 |
-
;;
|
722 |
-
*)
|
723 |
-
if [ -z "$lsb_dist" ]; then
|
724 |
-
if is_darwin; then
|
725 |
-
echo
|
726 |
-
echo "ERROR: Unsupported operating system 'macOS'"
|
727 |
-
echo "Please get Docker Desktop from https://www.docker.com/products/docker-desktop"
|
728 |
-
echo
|
729 |
-
exit 1
|
730 |
-
fi
|
731 |
-
fi
|
732 |
-
echo
|
733 |
-
echo "ERROR: Unsupported distribution '$lsb_dist'"
|
734 |
-
echo
|
735 |
-
exit 1
|
736 |
-
;;
|
737 |
-
esac
|
738 |
-
exit 1
|
739 |
-
}
|
740 |
-
|
741 |
-
# wrapped up in a function so that we have some protection against only getting
|
742 |
-
# half the file during "curl | sh"
|
743 |
-
do_install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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