install.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  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. # For test builds (ie. release candidates):
  10. # 'curl -fsSL https://test.docker.com/ | sh'
  11. # or:
  12. # 'wget -qO- https://test.docker.com/ | sh'
  13. #
  14. # For experimental builds:
  15. # 'curl -fsSL https://experimental.docker.com/ | sh'
  16. # or:
  17. # 'wget -qO- https://experimental.docker.com/ | sh'
  18. #
  19. # Docker Maintainers:
  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
  24. #
  25. url="https://get.docker.com/"
  26. apt_url="https://apt.dockerproject.org"
  27. yum_url="https://yum.dockerproject.org"
  28. docker_key="-----BEGIN PGP PUBLIC KEY BLOCK-----
  29. Version: GnuPG v1
  30. mQINBFWln24BEADrBl5p99uKh8+rpvqJ48u4eTtjeXAWbslJotmC/CakbNSqOb9o
  31. ddfzRvGVeJVERt/Q/mlvEqgnyTQy+e6oEYN2Y2kqXceUhXagThnqCoxcEJ3+KM4R
  32. mYdoe/BJ/J/6rHOjq7Omk24z2qB3RU1uAv57iY5VGw5p45uZB4C4pNNsBJXoCvPn
  33. TGAs/7IrekFZDDgVraPx/hdiwopQ8NltSfZCyu/jPpWFK28TR8yfVlzYFwibj5WK
  34. dHM7ZTqlA1tHIG+agyPf3Rae0jPMsHR6q+arXVwMccyOi+ULU0z8mHUJ3iEMIrpT
  35. X+80KaN/ZjibfsBOCjcfiJSB/acn4nxQQgNZigna32velafhQivsNREFeJpzENiG
  36. HOoyC6qVeOgKrRiKxzymj0FIMLru/iFF5pSWcBQB7PYlt8J0G80lAcPr6VCiN+4c
  37. NKv03SdvA69dCOj79PuO9IIvQsJXsSq96HB+TeEmmL+xSdpGtGdCJHHM1fDeCqkZ
  38. hT+RtBGQL2SEdWjxbF43oQopocT8cHvyX6Zaltn0svoGs+wX3Z/H6/8P5anog43U
  39. 65c0A+64Jj00rNDr8j31izhtQMRo892kGeQAaaxg4Pz6HnS7hRC+cOMHUU4HA7iM
  40. zHrouAdYeTZeZEQOA7SxtCME9ZnGwe2grxPXh/U/80WJGkzLFNcTKdv+rwARAQAB
  41. tDdEb2NrZXIgUmVsZWFzZSBUb29sIChyZWxlYXNlZG9ja2VyKSA8ZG9ja2VyQGRv
  42. Y2tlci5jb20+iQIcBBABCgAGBQJWw7vdAAoJEFyzYeVS+w0QHysP/i37m4SyoOCV
  43. cnybl18vzwBEcp4VCRbXvHvOXty1gccVIV8/aJqNKgBV97lY3vrpOyiIeB8ETQeg
  44. srxFE7t/Gz0rsLObqfLEHdmn5iBJRkhLfCpzjeOnyB3Z0IJB6UogO/msQVYe5CXJ
  45. l6uwr0AmoiCBLrVlDAktxVh9RWch0l0KZRX2FpHu8h+uM0/zySqIidlYfLa3y5oH
  46. scU+nGU1i6ImwDTD3ysZC5jp9aVfvUmcESyAb4vvdcAHR+bXhA/RW8QHeeMFliWw
  47. 7Z2jYHyuHmDnWG2yUrnCqAJTrWV+OfKRIzzJFBs4e88ru5h2ZIXdRepw/+COYj34
  48. LyzxR2cxr2u/xvxwXCkSMe7F4KZAphD+1ws61FhnUMi/PERMYfTFuvPrCkq4gyBj
  49. t3fFpZ2NR/fKW87QOeVcn1ivXl9id3MMs9KXJsg7QasT7mCsee2VIFsxrkFQ2jNp
  50. D+JAERRn9Fj4ArHL5TbwkkFbZZvSi6fr5h2GbCAXIGhIXKnjjorPY/YDX6X8AaHO
  51. W1zblWy/CFr6VFl963jrjJgag0G6tNtBZLrclZgWhOQpeZZ5Lbvz2ZA5CqRrfAVc
  52. wPNW1fObFIRtqV6vuVluFOPCMAAnOnqR02w9t17iVQjO3oVN0mbQi9vjuExXh1Yo
  53. ScVetiO6LSmlQfVEVRTqHLMgXyR/EMo7iQIcBBABCgAGBQJXSWBlAAoJEFyzYeVS
  54. +w0QeH0QAI6btAfYwYPuAjfRUy9qlnPhZ+xt1rnwsUzsbmo8K3XTNh+l/R08nu0d
  55. sczw30Q1wju28fh1N8ay223+69f0+yICaXqR18AbGgFGKX7vo0gfEVaxdItUN3eH
  56. NydGFzmeOKbAlrxIMECnSTG/TkFVYO9Ntlv9vSN2BupmTagTRErxLZKnVsWRzp+X
  57. elwlgU5BCZ6U6Ze8+bIc6F1bZstf17X8i6XNV/rOCLx2yP0hn1osoljoLPpW8nzk
  58. wvqYsYbCA28lMt1aqe0UWvRCqR0zxlKn17NZQqjbxcajEMCajoQ01MshmO5GWePV
  59. iv2abCZ/iaC5zKqVT3deMJHLq7lum6qhA41E9gJH9QoqT+qgadheeFfoC1QP7cke
  60. +tXmYg2R39p3l5Hmm+JQbP4f9V5mpWExvHGCSbcatr35tnakIJZugq2ogzsm1djC
  61. Sz9222RXl9OoFqsm1bNzA78+/cOt5N2cyhU0bM2T/zgh42YbDD+JDU/HSmxUIpU+
  62. wrGvZGM2FU/up0DRxOC4U1fL6HHlj8liNJWfEg3vhougOh66gGF9ik5j4eIlNoz6
  63. lst+gmvlZQ9/9hRDeoG+AbhZeIlQ4CCw+Y1j/+fUxIzKHPVK+aFJd+oJVNvbojJW
  64. /SgDdSMtFwqOvXyYcHl30Ws0gZUeDyAmNGZeJ3kFklnApDmeKK+OiQIiBBABCgAM
  65. BQJXe5zTBYMHhh+AAAoJEDG4FaMBBnSp7YMQAJqrXoBonZAq07B6qUaT3aBCgnY4
  66. JshbXmFb/XrrS75f7YJDPx2fJJdqrbYDIHHgOjzxvp3ngPpOpJzI5sYmkaugeoCO
  67. /KHu/+39XqgTB7fguzapRfbvuWp+qzPcHSdb9opnagfzKAze3DQnnLiwCPlsyvGp
  68. zC4KzXgV2ze/4raaOye1kK7O0cHyapmn/q/TR3S8YapyXq5VpLThwJAw1SRDu0Yx
  69. eXIAQiIfaSxT79EktoioW2CSV8/djt+gBjXnKYJJA8P1zzX7GNt/Rc2YG0Ot4v6t
  70. BW16xqFTg+n5JzbeK5cZ1jbIXXfCcaZJyiM2MzYGhSJ9+EV7JYF05OAIWE4SGTRj
  71. XMquQ2oMLSwMCPQHm+FCD9PXQ0tHYx6tKT34wksdmoWsdejl/n3NS+178mG1WI/l
  72. N079h3im2gRwOykMou/QWs3vGw/xDoOYHPV2gJ7To9BLVnVK/hROgdFLZFeyRScN
  73. zwKm57HmYMFA74tX601OiHhk1ymP2UUc25oDWpLXlfcRULJJlo/KfZZF3pmKwIq3
  74. CilGayFUi1NNwuavG76EcAVtVFUVFFIITwkhkuRbBHIytzEHYosFgD5/acK0Pauq
  75. JnwrwKv0nWq3aK7nKiALAD+iZvPNjFZau3/APqLEmvmRnAElmugcHsWREFxMMjMM
  76. VgYFiYKUAJO8u46eiQI4BBMBAgAiBQJVpZ9uAhsvBgsJCAcDAgYVCAIJCgsEFgID
  77. AQIeAQIXgAAKCRD3YiFXLFJgnbRfEAC9Uai7Rv20QIDlDogRzd+Vebg4ahyoUdj0
  78. CH+nAk40RIoq6G26u1e+sdgjpCa8jF6vrx+smpgd1HeJdmpahUX0XN3X9f9qU9oj
  79. 9A4I1WDalRWJh+tP5WNv2ySy6AwcP9QnjuBMRTnTK27pk1sEMg9oJHK5p+ts8hlS
  80. C4SluyMKH5NMVy9c+A9yqq9NF6M6d6/ehKfBFFLG9BX+XLBATvf1ZemGVHQusCQe
  81. bTGv0C0V9yqtdPdRWVIEhHxyNHATaVYOafTj/EF0lDxLl6zDT6trRV5n9F1VCEh4
  82. Aal8L5MxVPcIZVO7NHT2EkQgn8CvWjV3oKl2GopZF8V4XdJRl90U/WDv/6cmfI08
  83. GkzDYBHhS8ULWRFwGKobsSTyIvnbk4NtKdnTGyTJCQ8+6i52s+C54PiNgfj2ieNn
  84. 6oOR7d+bNCcG1CdOYY+ZXVOcsjl73UYvtJrO0Rl/NpYERkZ5d/tzw4jZ6FCXgggA
  85. /Zxcjk6Y1ZvIm8Mt8wLRFH9Nww+FVsCtaCXJLP8DlJLASMD9rl5QS9Ku3u7ZNrr5
  86. HWXPHXITX660jglyshch6CWeiUATqjIAzkEQom/kEnOrvJAtkypRJ59vYQOedZ1s
  87. FVELMXg2UCkD/FwojfnVtjzYaTCeGwFQeqzHmM241iuOmBYPeyTY5veF49aBJA1g
  88. EJOQTvBR8Q==
  89. =Yhur
  90. -----END PGP PUBLIC KEY BLOCK-----
  91. "
  92. mirror=''
  93. while [ $# -gt 0 ]; do
  94. case "$1" in
  95. --mirror)
  96. mirror="$2"
  97. shift
  98. ;;
  99. *)
  100. echo "Illegal option $1"
  101. ;;
  102. esac
  103. shift $(( $# > 0 ? 1 : 0 ))
  104. done
  105. case "$mirror" in
  106. AzureChinaCloud)
  107. apt_url="https://mirror.azure.cn/docker-engine/apt"
  108. yum_url="https://mirror.azure.cn/docker-engine/yum"
  109. ;;
  110. Aliyun)
  111. apt_url="https://mirrors.aliyun.com/docker-engine/apt"
  112. yum_url="https://mirrors.aliyun.com/docker-engine/yum"
  113. ;;
  114. esac
  115. command_exists() {
  116. command -v "$@" > /dev/null 2>&1
  117. }
  118. echo_docker_as_nonroot() {
  119. if command_exists docker && [ -e /var/run/docker.sock ]; then
  120. (
  121. set -x
  122. $sh_c 'docker version'
  123. ) || true
  124. fi
  125. your_user=your-user
  126. [ "$user" != 'root' ] && your_user="$user"
  127. # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-EOF", spaces are kept in the output
  128. cat <<-EOF
  129. If you would like to use Docker as a non-root user, you should now consider
  130. adding your user to the "docker" group with something like:
  131. sudo usermod -aG docker $your_user
  132. Remember that you will have to log out and back in for this to take effect!
  133. WARNING: Adding a user to the "docker" group will grant the ability to run
  134. containers which can be used to obtain root privileges on the
  135. docker host.
  136. Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
  137. for more information.
  138. EOF
  139. }
  140. # Check if this is a forked Linux distro
  141. check_forked() {
  142. # Check for lsb_release command existence, it usually exists in forked distros
  143. if command_exists lsb_release; then
  144. # Check if the `-u` option is supported
  145. set +e
  146. lsb_release -a -u > /dev/null 2>&1
  147. lsb_release_exit_code=$?
  148. set -e
  149. # Check if the command has exited successfully, it means we're in a forked distro
  150. if [ "$lsb_release_exit_code" = "0" ]; then
  151. # Print info about current distro
  152. cat <<-EOF
  153. You're using '$lsb_dist' version '$dist_version'.
  154. EOF
  155. # Get the upstream release info
  156. lsb_dist=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'id' | cut -d ':' -f 2 | tr -d '[[:space:]]')
  157. dist_version=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'codename' | cut -d ':' -f 2 | tr -d '[[:space:]]')
  158. # Print info about upstream distro
  159. cat <<-EOF
  160. Upstream release is '$lsb_dist' version '$dist_version'.
  161. EOF
  162. else
  163. if [ -r /etc/debian_version ] && [ "$lsb_dist" != "ubuntu" ] && [ "$lsb_dist" != "raspbian" ]; then
  164. # We're Debian and don't even know it!
  165. lsb_dist=debian
  166. dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
  167. case "$dist_version" in
  168. 9)
  169. dist_version="stretch"
  170. ;;
  171. 8|'Kali Linux 2')
  172. dist_version="jessie"
  173. ;;
  174. 7)
  175. dist_version="wheezy"
  176. ;;
  177. esac
  178. fi
  179. fi
  180. fi
  181. }
  182. semverParse() {
  183. major="${1%%.*}"
  184. minor="${1#$major.}"
  185. minor="${minor%%.*}"
  186. patch="${1#$major.$minor.}"
  187. patch="${patch%%[-.]*}"
  188. }
  189. do_install() {
  190. architecture=$(uname -m)
  191. case $architecture in
  192. # officially supported
  193. amd64|x86_64)
  194. ;;
  195. # unofficially supported with available repositories
  196. armv6l|armv7l)
  197. ;;
  198. # unofficially supported without available repositories
  199. aarch64|arm64|ppc64le|s390x)
  200. cat 1>&2 <<-EOF
  201. Error: This install script does not support $architecture, because no
  202. $architecture package exists in Docker's repositories.
  203. Other install options include checking your distribution's package repository
  204. for a version of Docker, or building Docker from source.
  205. EOF
  206. exit 1
  207. ;;
  208. # not supported
  209. *)
  210. cat >&2 <<-EOF
  211. Error: $architecture is not a recognized platform.
  212. EOF
  213. exit 1
  214. ;;
  215. esac
  216. if command_exists docker; then
  217. version="$(docker -v | cut -d ' ' -f3 | cut -d ',' -f1)"
  218. MAJOR_W=1
  219. MINOR_W=10
  220. semverParse $version
  221. shouldWarn=0
  222. if [ $major -lt $MAJOR_W ]; then
  223. shouldWarn=1
  224. fi
  225. if [ $major -le $MAJOR_W ] && [ $minor -lt $MINOR_W ]; then
  226. shouldWarn=1
  227. fi
  228. cat >&2 <<-'EOF'
  229. Warning: the "docker" command appears to already exist on this system.
  230. If you already have Docker installed, this script can cause trouble, which is
  231. why we're displaying this warning and provide the opportunity to cancel the
  232. installation.
  233. If you installed the current Docker package using this script and are using it
  234. EOF
  235. if [ $shouldWarn -eq 1 ]; then
  236. cat >&2 <<-'EOF'
  237. again to update Docker, we urge you to migrate your image store before upgrading
  238. to v1.10+.
  239. You can find instructions for this here:
  240. https://github.com/docker/docker/wiki/Engine-v1.10.0-content-addressability-migration
  241. EOF
  242. else
  243. cat >&2 <<-'EOF'
  244. again to update Docker, you can safely ignore this message.
  245. EOF
  246. fi
  247. cat >&2 <<-'EOF'
  248. You may press Ctrl+C now to abort this script.
  249. EOF
  250. ( set -x; sleep 20 )
  251. fi
  252. user="$(id -un 2>/dev/null || true)"
  253. sh_c='sh -c'
  254. if [ "$user" != 'root' ]; then
  255. if command_exists sudo; then
  256. sh_c='sudo -E sh -c'
  257. elif command_exists su; then
  258. sh_c='su -c'
  259. else
  260. cat >&2 <<-'EOF'
  261. Error: this installer needs the ability to run commands as root.
  262. We are unable to find either "sudo" or "su" available to make this happen.
  263. EOF
  264. exit 1
  265. fi
  266. fi
  267. curl=''
  268. if command_exists curl; then
  269. curl='curl -sSL'
  270. elif command_exists wget; then
  271. curl='wget -qO-'
  272. elif command_exists busybox && busybox --list-modules | grep -q wget; then
  273. curl='busybox wget -qO-'
  274. fi
  275. # check to see which repo they are trying to install from
  276. if [ -z "$repo" ]; then
  277. repo='main'
  278. if [ "https://test.docker.com/" = "$url" ]; then
  279. repo='testing'
  280. elif [ "https://experimental.docker.com/" = "$url" ]; then
  281. repo='experimental'
  282. fi
  283. fi
  284. # perform some very rudimentary platform detection
  285. lsb_dist=''
  286. dist_version=''
  287. if command_exists lsb_release; then
  288. lsb_dist="$(lsb_release -si)"
  289. fi
  290. if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then
  291. lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
  292. fi
  293. if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then
  294. lsb_dist='debian'
  295. fi
  296. if [ -z "$lsb_dist" ] && [ -r /etc/fedora-release ]; then
  297. lsb_dist='fedora'
  298. fi
  299. if [ -z "$lsb_dist" ] && [ -r /etc/oracle-release ]; then
  300. lsb_dist='oracleserver'
  301. fi
  302. if [ -z "$lsb_dist" ] && [ -r /etc/centos-release ]; then
  303. lsb_dist='centos'
  304. fi
  305. if [ -z "$lsb_dist" ] && [ -r /etc/redhat-release ]; then
  306. lsb_dist='redhat'
  307. fi
  308. if [ -z "$lsb_dist" ] && [ -r /etc/photon-release ]; then
  309. lsb_dist='photon'
  310. fi
  311. if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then
  312. lsb_dist="$(. /etc/os-release && echo "$ID")"
  313. fi
  314. lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
  315. # Special case redhatenterpriseserver
  316. if [ "${lsb_dist}" = "redhatenterpriseserver" ]; then
  317. # Set it to redhat, it will be changed to centos below anyways
  318. lsb_dist='redhat'
  319. fi
  320. case "$lsb_dist" in
  321. ubuntu)
  322. if command_exists lsb_release; then
  323. dist_version="$(lsb_release --codename | cut -f2)"
  324. fi
  325. if [ -z "$dist_version" ] && [ -r /etc/lsb-release ]; then
  326. dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")"
  327. fi
  328. ;;
  329. debian|raspbian)
  330. dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
  331. case "$dist_version" in
  332. 9)
  333. dist_version="stretch"
  334. ;;
  335. 8)
  336. dist_version="jessie"
  337. ;;
  338. 7)
  339. dist_version="wheezy"
  340. ;;
  341. esac
  342. ;;
  343. oracleserver)
  344. # need to switch lsb_dist to match yum repo URL
  345. lsb_dist="oraclelinux"
  346. dist_version="$(rpm -q --whatprovides redhat-release --queryformat "%{VERSION}\n" | sed 's/\/.*//' | sed 's/\..*//' | sed 's/Server*//')"
  347. ;;
  348. fedora|centos|redhat)
  349. dist_version="$(rpm -q --whatprovides ${lsb_dist}-release --queryformat "%{VERSION}\n" | sed 's/\/.*//' | sed 's/\..*//' | sed 's/Server*//' | sort | tail -1)"
  350. ;;
  351. "vmware photon")
  352. lsb_dist="photon"
  353. dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
  354. ;;
  355. *)
  356. if command_exists lsb_release; then
  357. dist_version="$(lsb_release --codename | cut -f2)"
  358. fi
  359. if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
  360. dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
  361. fi
  362. ;;
  363. esac
  364. # Check if this is a forked Linux distro
  365. check_forked
  366. # Run setup for each distro accordingly
  367. case "$lsb_dist" in
  368. ubuntu|debian|raspbian)
  369. export DEBIAN_FRONTEND=noninteractive
  370. did_apt_get_update=
  371. apt_get_update() {
  372. if [ -z "$did_apt_get_update" ]; then
  373. ( set -x; $sh_c 'sleep 3; apt-get update' )
  374. did_apt_get_update=1
  375. fi
  376. }
  377. if [ "$lsb_dist" != "raspbian" ]; then
  378. # aufs is preferred over devicemapper; try to ensure the driver is available.
  379. if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
  380. if uname -r | grep -q -- '-generic' && dpkg -l 'linux-image-*-generic' | grep -qE '^ii|^hi' 2>/dev/null; then
  381. kern_extras="linux-image-extra-$(uname -r) linux-image-extra-virtual"
  382. apt_get_update
  383. ( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true
  384. if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
  385. echo >&2 'Warning: tried to install '"$kern_extras"' (for AUFS)'
  386. echo >&2 ' but we still have no AUFS. Docker may not work. Proceeding anyways!'
  387. ( set -x; sleep 10 )
  388. fi
  389. else
  390. echo >&2 'Warning: current kernel is not supported by the linux-image-extra-virtual'
  391. echo >&2 ' package. We have no AUFS support. Consider installing the packages'
  392. echo >&2 ' "linux-image-virtual" and "linux-image-extra-virtual" for AUFS support.'
  393. ( set -x; sleep 10 )
  394. fi
  395. fi
  396. fi
  397. # install apparmor utils if they're missing and apparmor is enabled in the kernel
  398. # otherwise Docker will fail to start
  399. if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then
  400. if command -v apparmor_parser >/dev/null 2>&1; then
  401. echo 'apparmor is enabled in the kernel and apparmor utils were already installed'
  402. else
  403. echo 'apparmor is enabled in the kernel, but apparmor_parser is missing. Trying to install it..'
  404. apt_get_update
  405. ( set -x; $sh_c 'sleep 3; apt-get install -y -q apparmor' )
  406. fi
  407. fi
  408. if [ ! -e /usr/lib/apt/methods/https ]; then
  409. apt_get_update
  410. ( set -x; $sh_c 'sleep 3; apt-get install -y -q apt-transport-https ca-certificates' )
  411. fi
  412. if [ -z "$curl" ]; then
  413. apt_get_update
  414. ( set -x; $sh_c 'sleep 3; apt-get install -y -q curl ca-certificates' )
  415. curl='curl -sSL'
  416. fi
  417. if ! command -v gpg > /dev/null; then
  418. apt_get_update
  419. ( set -x; $sh_c 'sleep 3; apt-get install -y -q gnupg2 || apt-get install -y -q gnupg' )
  420. fi
  421. # dirmngr is a separate package in ubuntu yakkety; see https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1634464
  422. if ! command -v dirmngr > /dev/null; then
  423. apt_get_update
  424. ( set -x; $sh_c 'sleep 3; apt-get install -y -q dirmngr' )
  425. fi
  426. (
  427. set -x
  428. echo "$docker_key" | $sh_c 'apt-key add -'
  429. $sh_c "mkdir -p /etc/apt/sources.list.d"
  430. $sh_c "echo deb \[arch=$(dpkg --print-architecture)\] ${apt_url}/repo ${lsb_dist}-${dist_version} ${repo} > /etc/apt/sources.list.d/docker.list"
  431. $sh_c 'sleep 3; apt-get update; apt-get install -y -q docker-engine'
  432. )
  433. echo_docker_as_nonroot
  434. exit 0
  435. ;;
  436. fedora|centos|redhat|oraclelinux|photon)
  437. if [ "${lsb_dist}" = "redhat" ]; then
  438. # we use the centos repository for both redhat and centos releases
  439. lsb_dist='centos'
  440. fi
  441. $sh_c "cat >/etc/yum.repos.d/docker-${repo}.repo" <<-EOF
  442. [docker-${repo}-repo]
  443. name=Docker ${repo} Repository
  444. baseurl=${yum_url}/repo/${repo}/${lsb_dist}/${dist_version}
  445. enabled=1
  446. gpgcheck=1
  447. gpgkey=${yum_url}/gpg
  448. EOF
  449. if [ "$lsb_dist" = "fedora" ] && [ "$dist_version" -ge "22" ]; then
  450. (
  451. set -x
  452. $sh_c 'sleep 3; dnf -y -q install docker-engine'
  453. )
  454. elif [ "$lsb_dist" = "photon" ]; then
  455. (
  456. set -x
  457. $sh_c 'sleep 3; tdnf -y install docker-engine'
  458. )
  459. else
  460. (
  461. set -x
  462. $sh_c 'sleep 3; yum -y -q install docker-engine'
  463. )
  464. fi
  465. echo_docker_as_nonroot
  466. exit 0
  467. ;;
  468. esac
  469. # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-'EOF'", spaces are kept in the output
  470. cat >&2 <<-'EOF'
  471. Either your platform is not easily detectable, is not supported by this
  472. installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have
  473. a package for Docker. Please visit the following URL for more detailed
  474. installation instructions:
  475. https://docs.docker.com/engine/installation/
  476. EOF
  477. exit 1
  478. }
  479. # wrapped up in a function so that we have some protection against only getting
  480. # half the file during "curl | sh"
  481. do_install