github.com/grubernaut/docker@v1.6.0-rc2/hack/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 if uname -r | grep -q -- '-generic' && dpkg -l 'linux-image-*-generic' | grep -q '^ii' 2>/dev/null; then 129 kern_extras="linux-image-extra-$(uname -r) linux-image-extra-virtual" 130 131 apt_get_update 132 ( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true 133 134 if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then 135 echo >&2 'Warning: tried to install '"$kern_extras"' (for AUFS)' 136 echo >&2 ' but we still have no AUFS. Docker may not work. Proceeding anyways!' 137 ( set -x; sleep 10 ) 138 fi 139 else 140 echo >&2 'Warning: current kernel is not supported by the linux-image-extra-virtual' 141 echo >&2 ' package. We have no AUFS support. Consider installing the packages' 142 echo >&2 ' linux-image-virtual kernel and linux-image-extra-virtual for AUFS support.' 143 ( set -x; sleep 10 ) 144 fi 145 fi 146 147 # install apparmor utils if they're missing and apparmor is enabled in the kernel 148 # otherwise Docker will fail to start 149 if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then 150 if command -v apparmor_parser &> /dev/null; then 151 echo 'apparmor is enabled in the kernel and apparmor utils were already installed' 152 else 153 echo 'apparmor is enabled in the kernel, but apparmor_parser missing' 154 apt_get_update 155 ( set -x; $sh_c 'sleep 3; apt-get install -y -q apparmor' ) 156 fi 157 fi 158 159 if [ ! -e /usr/lib/apt/methods/https ]; then 160 apt_get_update 161 ( set -x; $sh_c 'sleep 3; apt-get install -y -q apt-transport-https ca-certificates' ) 162 fi 163 if [ -z "$curl" ]; then 164 apt_get_update 165 ( set -x; $sh_c 'sleep 3; apt-get install -y -q curl ca-certificates' ) 166 curl='curl -sSL' 167 fi 168 ( 169 set -x 170 if [ "https://get.docker.com/" = "$url" ]; then 171 $sh_c "apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9" 172 elif [ "https://test.docker.com/" = "$url" ]; then 173 $sh_c "apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 740B314AE3941731B942C66ADF4FD13717AAD7D6" 174 else 175 $sh_c "$curl ${url}gpg | apt-key add -" 176 fi 177 $sh_c "echo deb ${url}ubuntu docker main > /etc/apt/sources.list.d/docker.list" 178 $sh_c 'sleep 3; apt-get update; apt-get install -y -q lxc-docker' 179 ) 180 if command_exists docker && [ -e /var/run/docker.sock ]; then 181 ( 182 set -x 183 $sh_c 'docker version' 184 ) || true 185 fi 186 your_user=your-user 187 [ "$user" != 'root' ] && your_user="$user" 188 echo 189 echo 'If you would like to use Docker as a non-root user, you should now consider' 190 echo 'adding your user to the "docker" group with something like:' 191 echo 192 echo ' sudo usermod -aG docker' $your_user 193 echo 194 echo 'Remember that you will have to log out and back in for this to take effect!' 195 echo 196 exit 0 197 ;; 198 199 gentoo) 200 if [ "$url" = "https://test.docker.com/" ]; then 201 echo >&2 202 echo >&2 ' You appear to be trying to install the latest nightly build in Gentoo.' 203 echo >&2 ' The portage tree should contain the latest stable release of Docker, but' 204 echo >&2 ' if you want something more recent, you can always use the live ebuild' 205 echo >&2 ' provided in the "docker" overlay available via layman. For more' 206 echo >&2 ' instructions, please see the following URL:' 207 echo >&2 ' https://github.com/tianon/docker-overlay#using-this-overlay' 208 echo >&2 ' After adding the "docker" overlay, you should be able to:' 209 echo >&2 ' emerge -av =app-emulation/docker-9999' 210 echo >&2 211 exit 1 212 fi 213 214 ( 215 set -x 216 $sh_c 'sleep 3; emerge app-emulation/docker' 217 ) 218 exit 0 219 ;; 220 esac 221 222 cat >&2 <<'EOF' 223 224 Either your platform is not easily detectable, is not supported by this 225 installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have 226 a package for Docker. Please visit the following URL for more detailed 227 installation instructions: 228 229 https://docs.docker.com/en/latest/installation/ 230 231 EOF 232 exit 1