4 # This script is meant for quick & easy install via:
5 # 'curl -sSL https://get.docker.com/ | sh'
7 # 'wget -qO- https://get.docker.com/ | sh'
9 # For test builds (ie. release candidates):
10 # 'curl -fsSL https://test.docker.com/ | sh'
12 # 'wget -qO- https://test.docker.com/ | sh'
14 # For experimental builds:
15 # 'curl -fsSL https://experimental.docker.com/ | sh'
17 # 'wget -qO- https://experimental.docker.com/ | sh'
20 # To update this script on https://get.docker.com,
21 # use hack/release.sh during a normal release,
22 # or the following one-liner for script hotfixes:
23 # aws s3 cp --acl public-read hack/install.sh s3://get.docker.com/index
26 url="https://get.docker.com/"
27 apt_url="https://apt.dockerproject.org"
28 yum_url="https://yum.dockerproject.org"
30 docker_key="-----BEGIN PGP PUBLIC KEY BLOCK-----
33 mQINBFWln24BEADrBl5p99uKh8+rpvqJ48u4eTtjeXAWbslJotmC/CakbNSqOb9o
34 ddfzRvGVeJVERt/Q/mlvEqgnyTQy+e6oEYN2Y2kqXceUhXagThnqCoxcEJ3+KM4R
35 mYdoe/BJ/J/6rHOjq7Omk24z2qB3RU1uAv57iY5VGw5p45uZB4C4pNNsBJXoCvPn
36 TGAs/7IrekFZDDgVraPx/hdiwopQ8NltSfZCyu/jPpWFK28TR8yfVlzYFwibj5WK
37 dHM7ZTqlA1tHIG+agyPf3Rae0jPMsHR6q+arXVwMccyOi+ULU0z8mHUJ3iEMIrpT
38 X+80KaN/ZjibfsBOCjcfiJSB/acn4nxQQgNZigna32velafhQivsNREFeJpzENiG
39 HOoyC6qVeOgKrRiKxzymj0FIMLru/iFF5pSWcBQB7PYlt8J0G80lAcPr6VCiN+4c
40 NKv03SdvA69dCOj79PuO9IIvQsJXsSq96HB+TeEmmL+xSdpGtGdCJHHM1fDeCqkZ
41 hT+RtBGQL2SEdWjxbF43oQopocT8cHvyX6Zaltn0svoGs+wX3Z/H6/8P5anog43U
42 65c0A+64Jj00rNDr8j31izhtQMRo892kGeQAaaxg4Pz6HnS7hRC+cOMHUU4HA7iM
43 zHrouAdYe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
97 while [ $# -gt 0 ]; do
104 echo "Illegal option $1"
107 shift $(( $# > 0 ? 1 : 0 ))
112 apt_url="https://mirror.azure.cn/docker-engine/apt"
113 yum_url="https://mirror.azure.cn/docker-engine/yum"
116 apt_url="https://mirrors.aliyun.com/docker-engine/apt"
117 yum_url="https://mirrors.aliyun.com/docker-engine/yum"
122 command -v "$@" > /dev/null 2>&1
125 echo_docker_as_nonroot() {
126 if command_exists docker && [ -e /var/run/docker.sock ]; then
129 $sh_c 'docker version'
133 [ "$user" != 'root' ] && your_user="$user"
134 # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-EOF", spaces are kept in the output
137 If you would like to use Docker as a non-root user, you should now consider
138 adding your user to the "docker" group with something like:
140 sudo usermod -aG docker $your_user
142 Remember that you will have to log out and back in for this to take effect!
144 WARNING: Adding a user to the "docker" group will grant the ability to run
145 containers which can be used to obtain root privileges on the
147 Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
148 for more information.
153 # Check if this is a forked Linux distro
156 # Check for lsb_release command existence, it usually exists in forked distros
157 if command_exists lsb_release; then
158 # Check if the `-u` option is supported
160 lsb_release -a -u > /dev/null 2>&1
161 lsb_release_exit_code=$?
164 # Check if the command has exited successfully, it means we're in a forked distro
165 if [ "$lsb_release_exit_code" = "0" ]; then
166 # Print info about current distro
168 You're using '$lsb_dist' version '$dist_version'.
171 # Get the upstream release info
172 lsb_dist=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'id' | cut -d ':' -f 2 | tr -d '[[:space:]]')
173 dist_version=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'codename' | cut -d ':' -f 2 | tr -d '[[:space:]]')
175 # Print info about upstream distro
177 Upstream release is '$lsb_dist' version '$dist_version'.
180 if [ -r /etc/debian_version ] && [ "$lsb_dist" != "ubuntu" ] && [ "$lsb_dist" != "raspbian" ]; then
181 # We're Debian and don't even know it!
183 dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
184 case "$dist_version" in
186 dist_version="stretch"
189 dist_version="jessie"
192 dist_version="wheezy"
204 patch="${1#$major.$minor.}"
205 patch="${patch%%[-.]*}"
209 architecture=$(uname -m)
210 case $architecture in
211 # officially supported
214 # unofficially supported with available repositories
217 # unofficially supported without available repositories
218 aarch64|arm64|ppc64le|s390x)
220 Error: This install script does not support $architecture, because no
221 $architecture package exists in Docker's repositories.
223 Other install options include checking your distribution's package repository
224 for a version of Docker, or building Docker from source.
231 Error: $architecture is not a recognized platform.
237 if command_exists docker; then
238 version="$(docker -v | cut -d ' ' -f3 | cut -d ',' -f1)"
245 if [ $major -lt $MAJOR_W ]; then
249 if [ $major -le $MAJOR_W ] && [ $minor -lt $MINOR_W ]; then
254 Warning: the "docker" command appears to already exist on this system.
256 If you already have Docker installed, this script can cause trouble, which is
257 why we're displaying this warning and provide the opportunity to cancel the
260 If you installed the current Docker package using this script and are using it
263 if [ $shouldWarn -eq 1 ]; then
265 again to update Docker, we urge you to migrate your image store before upgrading
268 You can find instructions for this here:
269 https://github.com/docker/docker/wiki/Engine-v1.10.0-content-addressability-migration
273 again to update Docker, you can safely ignore this message.
279 You may press Ctrl+C now to abort this script.
284 user="$(id -un 2>/dev/null || true)"
287 if [ "$user" != 'root' ]; then
288 if command_exists sudo; then
290 elif command_exists su; then
294 Error: this installer needs the ability to run commands as root.
295 We are unable to find either "sudo" or "su" available to make this happen.
302 if command_exists curl; then
304 elif command_exists wget; then
306 elif command_exists busybox && busybox --list-modules | grep -q wget; then
307 curl='busybox wget -qO-'
310 # check to see which repo they are trying to install from
311 if [ -z "$repo" ]; then
313 if [ "https://test.docker.com/" = "$url" ]; then
315 elif [ "https://experimental.docker.com/" = "$url" ]; then
320 # perform some very rudimentary platform detection
323 if command_exists lsb_release; then
324 lsb_dist="$(lsb_release -si)"
326 if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then
327 lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
329 if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then
332 if [ -z "$lsb_dist" ] && [ -r /etc/fedora-release ]; then
335 if [ -z "$lsb_dist" ] && [ -r /etc/oracle-release ]; then
336 lsb_dist='oracleserver'
338 if [ -z "$lsb_dist" ] && [ -r /etc/centos-release ]; then
341 if [ -z "$lsb_dist" ] && [ -r /etc/redhat-release ]; then
344 if [ -z "$lsb_dist" ] && [ -r /etc/photon-release ]; then
347 if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then
348 lsb_dist="$(. /etc/os-release && echo "$ID")"
351 lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
353 # Special case redhatenterpriseserver
354 if [ "${lsb_dist}" = "redhatenterpriseserver" ]; then
355 # Set it to redhat, it will be changed to centos below anyways
362 if command_exists lsb_release; then
363 dist_version="$(lsb_release --codename | cut -f2)"
365 if [ -z "$dist_version" ] && [ -r /etc/lsb-release ]; then
366 dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")"
371 dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
372 case "$dist_version" in
374 dist_version="stretch"
377 dist_version="jessie"
380 dist_version="wheezy"
386 # need to switch lsb_dist to match yum repo URL
387 lsb_dist="oraclelinux"
388 dist_version="$(rpm -q --whatprovides redhat-release --queryformat "%{VERSION}\n" | sed 's/\/.*//' | sed 's/\..*//' | sed 's/Server*//')"
391 fedora|centos|redhat)
392 dist_version="$(rpm -q --whatprovides ${lsb_dist}-release --queryformat "%{VERSION}\n" | sed 's/\/.*//' | sed 's/\..*//' | sed 's/Server*//' | sort | tail -1)"
397 dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
401 if command_exists lsb_release; then
402 dist_version="$(lsb_release --codename | cut -f2)"
404 if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
405 dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
412 # Check if this is a forked Linux distro
415 # Run setup for each distro accordingly
417 ubuntu|debian|raspbian)
418 export DEBIAN_FRONTEND=noninteractive
422 if [ -z "$did_apt_get_update" ]; then
423 ( set -x; $sh_c 'sleep 3; apt-get update' )
428 if [ "$lsb_dist" != "raspbian" ]; then
429 # aufs is preferred over devicemapper; try to ensure the driver is available.
430 if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
431 if uname -r | grep -q -- '-generic' && dpkg -l 'linux-image-*-generic' | grep -qE '^ii|^hi' 2>/dev/null; then
432 kern_extras="linux-image-extra-$(uname -r) linux-image-extra-virtual"
435 ( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true
437 if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
438 echo >&2 'Warning: tried to install '"$kern_extras"' (for AUFS)'
439 echo >&2 ' but we still have no AUFS. Docker may not work. Proceeding anyways!'
443 echo >&2 'Warning: current kernel is not supported by the linux-image-extra-virtual'
444 echo >&2 ' package. We have no AUFS support. Consider installing the packages'
445 echo >&2 ' "linux-image-virtual" and "linux-image-extra-virtual" for AUFS support.'
451 # install apparmor utils if they're missing and apparmor is enabled in the kernel
452 # otherwise Docker will fail to start
453 if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then
454 if command -v apparmor_parser >/dev/null 2>&1; then
455 echo 'apparmor is enabled in the kernel and apparmor utils were already installed'
457 echo 'apparmor is enabled in the kernel, but apparmor_parser is missing. Trying to install it..'
459 ( set -x; $sh_c 'sleep 3; apt-get install -y -q apparmor' )
463 if [ ! -e /usr/lib/apt/methods/https ]; then
465 ( set -x; $sh_c 'sleep 3; apt-get install -y -q apt-transport-https ca-certificates' )
467 if [ -z "$curl" ]; then
469 ( set -x; $sh_c 'sleep 3; apt-get install -y -q curl ca-certificates' )
472 if ! command -v gpg > /dev/null; then
474 ( set -x; $sh_c 'sleep 3; apt-get install -y -q gnupg2 || apt-get install -y -q gnupg' )
477 # dirmngr is a separate package in ubuntu yakkety; see https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1634464
478 if ! command -v dirmngr > /dev/null; then
480 ( set -x; $sh_c 'sleep 3; apt-get install -y -q dirmngr' )
485 echo "$docker_key" | $sh_c 'apt-key add -'
486 $sh_c "mkdir -p /etc/apt/sources.list.d"
487 $sh_c "echo deb \[arch=$(dpkg --print-architecture)\] ${apt_url}/repo ${lsb_dist}-${dist_version} ${repo} > /etc/apt/sources.list.d/docker.list"
488 $sh_c 'sleep 3; apt-get update; apt-get install -y -q docker-engine'
490 echo_docker_as_nonroot
494 fedora|centos|redhat|oraclelinux|photon)
495 if [ "${lsb_dist}" = "redhat" ]; then
496 # we use the centos repository for both redhat and centos releases
499 $sh_c "cat >/etc/yum.repos.d/docker-${repo}.repo" <<-EOF
500 [docker-${repo}-repo]
501 name=Docker ${repo} Repository
502 baseurl=${yum_url}/repo/${repo}/${lsb_dist}/${dist_version}
505 gpgkey=${yum_url}/gpg
507 if [ "$lsb_dist" = "fedora" ] && [ "$dist_version" -ge "22" ]; then
510 $sh_c 'sleep 3; dnf -y -q install docker-engine'
512 elif [ "$lsb_dist" = "photon" ]; then
515 $sh_c 'sleep 3; tdnf -y install docker-engine'
520 $sh_c 'sleep 3; yum -y -q install docker-engine'
523 echo_docker_as_nonroot
528 # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-'EOF'", spaces are kept in the output
531 Either your platform is not easily detectable, is not supported by this
532 installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have
533 a package for Docker. Please visit the following URL for more detailed
534 installation instructions:
536 https://docs.docker.com/engine/installation/
542 # wrapped up in a function so that we have some protection against only getting
543 # half the file during "curl | sh"