github.com/raychaser/docker@v1.5.0/project/install.sh (about) 1 #!/bin/sh 2 set -e 3 # 4 # This script is meant for quick & easy install via: 5 # 'curl -sSL https://get.docker.com/ | sh' 6 # or: 7 # 'wget -qO- https://get.docker.com/ | sh' 8 # 9 # 10 # Docker Maintainers: 11 # To update this script on https://get.docker.com, 12 # use hack/release.sh during a normal release, 13 # or the following one-liner for script hotfixes: 14 # s3cmd put --acl-public -P hack/install.sh s3://get.docker.com/index 15 # 16 17 url='https://get.docker.com/' 18 19 command_exists() { 20 command -v "$@" > /dev/null 2>&1 21 } 22 23 case "$(uname -m)" in 24 *64) 25 ;; 26 *) 27 echo >&2 'Error: you are not using a 64bit platform.' 28 echo >&2 'Docker currently only supports 64bit platforms.' 29 exit 1 30 ;; 31 esac 32 33 if command_exists docker || command_exists lxc-docker; then 34 echo >&2 'Warning: "docker" or "lxc-docker" command appears to already exist.' 35 echo >&2 'Please ensure that you do not already have docker installed.' 36 echo >&2 'You may press Ctrl+C now to abort this process and rectify this situation.' 37 ( set -x; sleep 20 ) 38 fi 39 40 user="$(id -un 2>/dev/null || true)" 41 42 sh_c='sh -c' 43 if [ "$user" != 'root' ]; then 44 if command_exists sudo; then 45 sh_c='sudo -E sh -c' 46 elif command_exists su; then 47 sh_c='su -c' 48 else 49 echo >&2 'Error: this installer needs the ability to run commands as root.' 50 echo >&2 'We are unable to find either "sudo" or "su" available to make this happen.' 51 exit 1 52 fi 53 fi 54 55 curl='' 56 if command_exists curl; then 57 curl='curl -sSL' 58 elif command_exists wget; then 59 curl='wget -qO-' 60 elif command_exists busybox && busybox --list-modules | grep -q wget; then 61 curl='busybox wget -qO-' 62 fi 63 64 # perform some very rudimentary platform detection 65 lsb_dist='' 66 if command_exists lsb_release; then 67 lsb_dist="$(lsb_release -si)" 68 fi 69 if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then 70 lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")" 71 fi 72 if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then 73 lsb_dist='debian' 74 fi 75 if [ -z "$lsb_dist" ] && [ -r /etc/fedora-release ]; then 76 lsb_dist='fedora' 77 fi 78 if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then 79 lsb_dist="$(. /etc/os-release && echo "$ID")" 80 fi 81 82 lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')" 83 case "$lsb_dist" in 84 amzn|fedora) 85 if [ "$lsb_dist" = 'amzn' ]; then 86 ( 87 set -x 88 $sh_c 'sleep 3; yum -y -q install docker' 89 ) 90 else 91 ( 92 set -x 93 $sh_c 'sleep 3; yum -y -q install docker-io' 94 ) 95 fi 96 if command_exists docker && [ -e /var/run/docker.sock ]; then 97 ( 98 set -x 99 $sh_c 'docker version' 100 ) || true 101 fi 102 your_user=your-user 103 [ "$user" != 'root' ] && your_user="$user" 104 echo 105 echo 'If you would like to use Docker as a non-root user, you should now consider' 106 echo 'adding your user to the "docker" group with something like:' 107 echo 108 echo ' sudo usermod -aG docker' $your_user 109 echo 110 echo 'Remember that you will have to log out and back in for this to take effect!' 111 echo 112 exit 0 113 ;; 114 115 ubuntu|debian|linuxmint) 116 export DEBIAN_FRONTEND=noninteractive 117 118 did_apt_get_update= 119 apt_get_update() { 120 if [ -z "$did_apt_get_update" ]; then 121 ( set -x; $sh_c 'sleep 3; apt-get update' ) 122 did_apt_get_update=1 123 fi 124 } 125 126 # aufs is preferred over devicemapper; try to ensure the driver is available. 127 if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then 128 kern_extras="linux-image-extra-$(uname -r)" 129 130 apt_get_update 131 ( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true 132 133 if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then 134 echo >&2 'Warning: tried to install '"$kern_extras"' (for AUFS)' 135 echo >&2 ' but we still have no AUFS. Docker may not work. Proceeding anyways!' 136 ( set -x; sleep 10 ) 137 fi 138 fi 139 140 # install apparmor utils if they're missing and apparmor is enabled in the kernel 141 # otherwise Docker will fail to start 142 if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then 143 if command -v apparmor_parser &> /dev/null; then 144 echo 'apparmor is enabled in the kernel and apparmor utils were already installed' 145 else 146 echo 'apparmor is enabled in the kernel, but apparmor_parser missing' 147 apt_get_update 148 ( set -x; $sh_c 'sleep 3; apt-get install -y -q apparmor' ) 149 fi 150 fi 151 152 if [ ! -e /usr/lib/apt/methods/https ]; then 153 apt_get_update 154 ( set -x; $sh_c 'sleep 3; apt-get install -y -q apt-transport-https' ) 155 fi 156 if [ -z "$curl" ]; then 157 apt_get_update 158 ( set -x; $sh_c 'sleep 3; apt-get install -y -q curl' ) 159 curl='curl -sSL' 160 fi 161 ( 162 set -x 163 if [ "https://get.docker.com/" = "$url" ]; then 164 $sh_c "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9" 165 elif [ "https://test.docker.com/" = "$url" ]; then 166 $sh_c "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 740B314AE3941731B942C66ADF4FD13717AAD7D6" 167 else 168 $sh_c "$curl ${url}gpg | apt-key add -" 169 fi 170 $sh_c "echo deb ${url}ubuntu docker main > /etc/apt/sources.list.d/docker.list" 171 $sh_c 'sleep 3; apt-get update; apt-get install -y -q lxc-docker' 172 ) 173 if command_exists docker && [ -e /var/run/docker.sock ]; then 174 ( 175 set -x 176 $sh_c 'docker version' 177 ) || true 178 fi 179 your_user=your-user 180 [ "$user" != 'root' ] && your_user="$user" 181 echo 182 echo 'If you would like to use Docker as a non-root user, you should now consider' 183 echo 'adding your user to the "docker" group with something like:' 184 echo 185 echo ' sudo usermod -aG docker' $your_user 186 echo 187 echo 'Remember that you will have to log out and back in for this to take effect!' 188 echo 189 exit 0 190 ;; 191 192 gentoo) 193 if [ "$url" = "https://test.docker.com/" ]; then 194 echo >&2 195 echo >&2 ' You appear to be trying to install the latest nightly build in Gentoo.' 196 echo >&2 ' The portage tree should contain the latest stable release of Docker, but' 197 echo >&2 ' if you want something more recent, you can always use the live ebuild' 198 echo >&2 ' provided in the "docker" overlay available via layman. For more' 199 echo >&2 ' instructions, please see the following URL:' 200 echo >&2 ' https://github.com/tianon/docker-overlay#using-this-overlay' 201 echo >&2 ' After adding the "docker" overlay, you should be able to:' 202 echo >&2 ' emerge -av =app-emulation/docker-9999' 203 echo >&2 204 exit 1 205 fi 206 207 ( 208 set -x 209 $sh_c 'sleep 3; emerge app-emulation/docker' 210 ) 211 exit 0 212 ;; 213 esac 214 215 cat >&2 <<'EOF' 216 217 Either your platform is not easily detectable, is not supported by this 218 installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have 219 a package for Docker. Please visit the following URL for more detailed 220 installation instructions: 221 222 https://docs.docker.com/en/latest/installation/ 223 224 EOF 225 exit 1