1. sh docker-install.sh 1.12.6 #ubuntu16.4 测试通过
  1. #!/bin/sh
  2. set -e
  3. #
  4. # This script is meant for quick & easy install via:
  5. # 'curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh'
  6. # or:
  7. # 'wget -qO- http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh'
  8. #
  9. # For test builds (ie. release candidates):
  10. # 'curl -fsSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/test/internet | sh'
  11. # or:
  12. # 'wget -qO- http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/test/internet | sh'
  13. #
  14. # For experimental builds:
  15. # 'curl -fsSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/experimental/internet | sh'
  16. # or:
  17. # 'wget -qO- http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/experimental/internet | 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.  
  26. url="http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet"
  27. apt_url="http://mirrors.aliyun.com/docker-engine/apt"
  28. yum_url="http://mirrors.aliyun.com/docker-engine/yum"
  29. gpg_fingerprint="58118E89F3A912897C070ADBF76221572C52609D"
  30.  
  31. key_servers="
  32. ha.pool.sks-keyservers.net
  33. pgp.mit.edu
  34. keyserver.ubuntu.com
  35. "
  36.  
  37. command_exists() {
  38. command -v "$@" > /dev/null >&
  39. }
  40.  
  41. echo_docker_as_nonroot() {
  42. if command_exists docker && [ -e /var/run/docker.sock ]; then
  43. (
  44. set -x
  45. $sh_c 'docker version'
  46. ) || true
  47. fi
  48. your_user=your-user
  49. [ "$user" != 'root' ] && your_user="$user"
  50. # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-EOF", spaces are kept in the output
  51. cat <<-EOF
  52.  
  53. If you would like to use Docker as a non-root user, you should now consider
  54. adding your user to the "docker" group with something like:
  55.  
  56. sudo usermod -aG docker $your_user
  57.  
  58. Remember that you will have to log out and back in for this to take effect!
  59.  
  60. EOF
  61. }
  62.  
  63. # Check if this is a forked Linux distro
  64. check_forked() {
  65.  
  66. # Check for lsb_release command existence, it usually exists in forked distros
  67. if command_exists lsb_release; then
  68. # Check if the `-u` option is supported
  69. set +e
  70. lsb_release -a -u > /dev/null >&
  71. lsb_release_exit_code=$?
  72. set -e
  73.  
  74. # Check if the command has exited successfully, it means we're in a forked distro
  75. if [ "$lsb_release_exit_code" = "" ]; then
  76. # Print info about current distro
  77. cat <<-EOF
  78. You're using '$lsb_dist' version '$dist_version'.
  79. EOF
  80.  
  81. # Get the upstream release info
  82. d '[[:space:]]')
  83. f | tr -d '[[:space:]]')
  84.  
  85. # Print info about upstream distro
  86. cat <<-EOF
  87. Upstream release is '$lsb_dist' version '$dist_version'.
  88. EOF
  89. else
  90. if [ -r /etc/debian_version ] && [ "$lsb_dist" != "ubuntu" ]; then
  91. # We're Debian and don't even know it!
  92. lsb_dist=debian
  93. dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
  94. case "$dist_version" in
  95. |'Kali Linux 2')
  96. dist_version="jessie"
  97. ;;
  98. )
  99. dist_version="wheezy"
  100. ;;
  101. esac
  102. fi
  103. fi
  104. fi
  105. }
  106.  
  107. rpm_import_repository_key() {
  108. local key=$; shift
  109. local tmpdir=$(mktemp -d)
  110. chmod "$tmpdir"
  111. for key_server in $key_servers ; do
  112. gpg --homedir "$tmpdir" --keyserver "$key_server" --recv-keys "$key" && break
  113. done
  114. gpg --homedir "$tmpdir" -k "$key" >/dev/null
  115. gpg --homedir "$tmpdir" --export --armor "$key" > "$tmpdir"/repo.key
  116. rpm --import "$tmpdir"/repo.key
  117. rm -rf "$tmpdir"
  118. }
  119.  
  120. semverParse() {
  121. major="${1%%.*}"
  122. minor="${1#$major.}"
  123. minor="${minor%%.*}"
  124. patch="${1#$major.$minor.}"
  125. patch="${patch%%[-.]*}"
  126. }
  127.  
  128. do_install() {
  129. case "$(uname -m)" in
  130. *)
  131. ;;
  132. *)
  133. cat >& <<-'EOF'
  134. Error: you are not using a 64bit platform.
  135. Docker currently only supports 64bit platforms.
  136. EOF
  137. exit
  138. ;;
  139. esac
  140.  
  141. if command_exists docker; then
  142. version="$(docker -v | awk -F '[ ,]+' '{ print $3 }')"
  143. MAJOR_W=
  144. MINOR_W=
  145.  
  146. semverParse $version
  147.  
  148. shouldWarn=
  149. if [ $major -lt $MAJOR_W ]; then
  150. shouldWarn=
  151. fi
  152.  
  153. if [ $major -le $MAJOR_W ] && [ $minor -lt $MINOR_W ]; then
  154. shouldWarn=
  155. fi
  156.  
  157. cat >& <<-'EOF'
  158. Warning: the "docker" command appears to already exist on this system.
  159.  
  160. If you already have Docker installed, this script can cause trouble, which is
  161. why we're displaying this warning and provide the opportunity to cancel the
  162. installation.
  163.  
  164. If you installed the current Docker package using this script and are using it
  165. EOF
  166.  
  167. if [ $shouldWarn -eq ]; then
  168. cat >& <<-'EOF'
  169. again to update Docker, we urge you to migrate your image store before upgrading
  170. to v1.+.
  171.  
  172. You can find instructions for this here:
  173. https://github.com/docker/docker/wiki/Engine-v1.10.0-content-addressability-migration
  174. EOF
  175. else
  176. cat >& <<-'EOF'
  177. again to update Docker, you can safely ignore this message.
  178. EOF
  179. fi
  180.  
  181. cat >& <<-'EOF'
  182.  
  183. You may press Ctrl+C now to abort this script.
  184. EOF
  185. ( set -x; sleep )
  186. fi
  187.  
  188. user="$(id -un 2>/dev/null || true)"
  189.  
  190. sh_c='sh -c'
  191. if [ "$user" != 'root' ]; then
  192. if command_exists sudo; then
  193. sh_c='sudo -E sh -c'
  194. elif command_exists su; then
  195. sh_c='su -c'
  196. else
  197. cat >& <<-'EOF'
  198. Error: this installer needs the ability to run commands as root.
  199. We are unable to find either "sudo" or "su" available to make this happen.
  200. EOF
  201. exit
  202. fi
  203. fi
  204.  
  205. curl=''
  206. if command_exists curl; then
  207. curl='curl -sSL'
  208. elif command_exists wget; then
  209. curl='wget -qO-'
  210. elif command_exists busybox && busybox --list-modules | grep -q wget; then
  211. curl='busybox wget -qO-'
  212. fi
  213.  
  214. # check to see which repo they are trying to install from
  215. if [ -z "$repo" ]; then
  216. repo='main'
  217. if [ "http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/test/internet" = "$url" ]; then
  218. repo='testing'
  219. then
  220. repo='experimental'
  221. fi
  222. fi
  223.  
  224. # perform some very rudimentary platform detection
  225. lsb_dist=''
  226. dist_version=''
  227. if command_exists lsb_release; then
  228. lsb_dist="$(lsb_release -si)"
  229. fi
  230. if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then
  231. lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
  232. fi
  233. if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then
  234. lsb_dist='debian'
  235. fi
  236. if [ -z "$lsb_dist" ] && [ -r /etc/fedora-release ]; then
  237. lsb_dist='fedora'
  238. fi
  239. if [ -z "$lsb_dist" ] && [ -r /etc/oracle-release ]; then
  240. lsb_dist='oracleserver'
  241. fi
  242. if [ -z "$lsb_dist" ]; then
  243. if [ -r /etc/centos-release ] || [ -r /etc/redhat-release ]; then
  244. lsb_dist='centos'
  245. fi
  246. fi
  247. if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then
  248. lsb_dist="$(. /etc/os-release && echo "$ID")"
  249. fi
  250.  
  251. lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
  252.  
  253. case "$lsb_dist" in
  254.  
  255. ubuntu)
  256. if command_exists lsb_release; then
  257. dist_version="$(lsb_release --codename | cut -f2)"
  258. fi
  259. if [ -z "$dist_version" ] && [ -r /etc/lsb-release ]; then
  260. dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")"
  261. fi
  262. ;;
  263.  
  264. debian)
  265. dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
  266. case "$dist_version" in
  267. )
  268. dist_version="jessie"
  269. ;;
  270. )
  271. dist_version="wheezy"
  272. ;;
  273. esac
  274. ;;
  275.  
  276. oracleserver)
  277. # need to switch lsb_dist to match yum repo URL
  278. lsb_dist="oraclelinux"
  279. ed 's/\..*//' | sed 's/Server*//' | sort -r | head -)"
  280. ;;
  281.  
  282. fedora|centos)
  283. ed 's/\..*//' | sed 's/Server*//' | sort -r | head -)"
  284. ;;
  285.  
  286. *)
  287. if command_exists lsb_release; then
  288. dist_version="$(lsb_release --codename | cut -f2)"
  289. fi
  290. if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
  291. dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
  292. fi
  293. ;;
  294.  
  295. esac
  296.  
  297. # Check if this is a forked Linux distro
  298. check_forked
  299.  
  300. # Run setup for each distro accordingly
  301. case "$lsb_dist" in
  302. amzn)
  303. (
  304. set -x
  305. $sh_c 'sleep 3; yum -y -q install docker'
  306. )
  307. echo_docker_as_nonroot
  308. exit
  309. ;;
  310.  
  311. 'opensuse project'|opensuse)
  312. echo 'Going to perform the following operations:'
  313. if [ "$repo" != 'main' ]; then
  314. echo ' * add repository obs://Virtualization:containers'
  315. fi
  316. echo ' * install Docker'
  317. $sh_c 'echo "Press CTRL-C to abort"; sleep 3'
  318.  
  319. if [ "$repo" != 'main' ]; then
  320. # install experimental packages from OBS://Virtualization:containers
  321. (
  322. set -x
  323. zypper -n ar -f obs://Virtualization:containers Virtualization:containers
  324. rpm_import_repository_key 55A0B34D49501BB7CA474F5AA193FBB572174FC2
  325. )
  326. fi
  327. (
  328. set -x
  329. zypper -n install docker
  330. )
  331. echo_docker_as_nonroot
  332. exit
  333. ;;
  334. 'suse linux'|sle[sd])
  335. echo 'Going to perform the following operations:'
  336. if [ "$repo" != 'main' ]; then
  337. echo ' * add repository obs://Virtualization:containers'
  338. echo ' * install experimental Docker using packages NOT supported by SUSE'
  339. else
  340. echo ' * add the "Containers" module'
  341. echo ' * install Docker using packages supported by SUSE'
  342. fi
  343. $sh_c 'echo "Press CTRL-C to abort"; sleep 3'
  344.  
  345. if [ "$repo" != 'main' ]; then
  346. # install experimental packages from OBS://Virtualization:containers
  347. by SUSE'
  348. (
  349. set -x
  350. zypper -n ar -f obs://Virtualization:containers/SLE_12 Virtualization:containers
  351. rpm_import_repository_key 55A0B34D49501BB7CA474F5AA193FBB572174FC2
  352. )
  353. else
  354. # Add the containers module
  355. # Note well-: the SLE machine must already be registered against SUSE Customer Center
  356. # Note well-: the `-r ""` is required to workaround a known issue of SUSEConnect
  357. (
  358. set -x
  359. SUSEConnect -p sle-module-containers//x86_64 -r ""
  360. )
  361. fi
  362. (
  363. set -x
  364. zypper -n install docker
  365. )
  366. echo_docker_as_nonroot
  367. exit
  368. ;;
  369.  
  370. ubuntu|debian)
  371. export DEBIAN_FRONTEND=noninteractive
  372.  
  373. did_apt_get_update=
  374. apt_get_update() {
  375. if [ -z "$did_apt_get_update" ]; then
  376. ( set -x; $sh_c 'sleep 3; apt-get update || true' )
  377. did_apt_get_update=
  378. fi
  379. }
  380.  
  381. # aufs is preferred over devicemapper; try to ensure the driver is available.
  382. if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
  383. /dev/null; then
  384. kern_extras="linux-image-extra-$(uname -r) linux-image-extra-virtual"
  385.  
  386. apt_get_update
  387. ( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true
  388.  
  389. if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
  390. echo >& 'Warning: tried to install '"$kern_extras"' (for AUFS)'
  391. !'
  392. ( set -x; sleep )
  393. fi
  394. else
  395. echo >& 'Warning: current kernel is not supported by the linux-image-extra-virtual'
  396. echo >& ' package. We have no AUFS support. Consider installing the packages'
  397. echo >& ' linux-image-virtual kernel and linux-image-extra-virtual for AUFS support.'
  398. ( set -x; sleep )
  399. fi
  400. fi
  401.  
  402. # install apparmor utils if they're missing and apparmor is enabled in the kernel
  403. # otherwise Docker will fail to start
  404. if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then
  405. if command -v apparmor_parser >/dev/null >&; then
  406. echo 'apparmor is enabled in the kernel and apparmor utils were already installed'
  407. else
  408. echo 'apparmor is enabled in the kernel, but apparmor_parser missing'
  409. apt_get_update
  410. ( set -x; $sh_c 'sleep 3; apt-get install -y -q apparmor' )
  411. fi
  412. fi
  413.  
  414. if [ ! -e /usr/lib/apt/methods/https ]; then
  415. apt_get_update
  416. ( set -x; $sh_c 'sleep 3; apt-get install -y -q apt-transport-https ca-certificates' )
  417. fi
  418. if [ -z "$curl" ]; then
  419. apt_get_update
  420. ( set -x; $sh_c 'sleep 3; apt-get install -y -q curl ca-certificates' )
  421. curl='curl -sSL'
  422. fi
  423. (
  424. set -x
  425. for key_server in $key_servers ; do
  426. $sh_c "apt-key adv --keyserver hkp://${key_server}:80 --recv-keys ${gpg_fingerprint}" && break
  427. done
  428. $sh_c "apt-key adv -k ${gpg_fingerprint} >/dev/null"
  429. $sh_c "mkdir -p /etc/apt/sources.list.d"
  430. } > /etc/apt/sources.list.d/docker.list"
  431. ker-engine; else apt-get install -y -q docker-engine=${docker_version}-~ubuntu-${dist_version}; fi"
  432. )
  433. echo_docker_as_nonroot
  434. exit
  435. ;;
  436.  
  437. fedora|centos|oraclelinux)
  438. $sh_c "cat >/etc/yum.repos.d/docker-${repo}.repo" <<-EOF
  439. [docker-${repo}-repo]
  440. name=Docker ${repo} Repository
  441. baseurl=${yum_url}/repo/${repo}/${lsb_dist}/${dist_version}
  442. enabled=
  443. gpgcheck=
  444. gpgkey=${yum_url}/gpg
  445. EOF
  446. if [ "$lsb_dist" = "fedora" ] && [ "$dist_version" -ge "" ]; then
  447. (
  448. set -x
  449. $sh_c 'sleep 3; dnf -y -q install docker-engine'
  450. )
  451. else
  452. (
  453. set -x
  454. ll docker-engine; else yum -y -q install docker-engine-$docker_version; fi"
  455. )
  456. fi
  457. echo_docker_as_nonroot
  458. exit
  459. ;;
  460. gentoo)
  461. hen
  462. in the output
  463. cat >& <<-'EOF'
  464.  
  465. You appear to be trying to install the latest nightly build in Gentoo.'
  466. The portage tree should contain the latest stable release of Docker, but'
  467. if you want something more recent, you can always use the live ebuild'
  468. provided in the "docker" overlay available via layman. For more'
  469. instructions, please see the following URL:'
  470.  
  471. https://github.com/tianon/docker-overlay#using-this-overlay'
  472.  
  473. After adding the "docker" overlay, you should be able to:'
  474.  
  475. emerge -av =app-emulation/docker-'
  476.  
  477. EOF
  478. exit
  479. fi
  480.  
  481. (
  482. set -x
  483. $sh_c 'sleep 3; emerge app-emulation/docker'
  484. )
  485. exit
  486. ;;
  487. esac
  488.  
  489. # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-'EOF'", spaces are kept in the output
  490. cat >& <<-'EOF'
  491.  
  492. Either your platform is not easily detectable, is not supported by this
  493. installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have
  494. a package for Docker. Please visit the following URL for more detailed
  495. installation instructions:
  496.  
  497. https://docs.docker.com/engine/installation/
  498.  
  499. EOF
  500. exit
  501. }
  502.  
  503. # wrapped up in a function so that we have some protection against only getting
  504. # half the file during "curl | sh"
  505. if [ ! -z $ ] ; then docker_version=$; fi
  506.  
  507. do_install

代码

加速器

  1. #!/bin/sh
  2. sudo mkdir -p /etc/docker
  3. sudo tee /etc/docker/daemon.json <<-'EOF'
  4. {
  5. "registry-mirrors": ["https://xxx.mirror.aliyuncs.com"]
  6. }
  7. EOF
  8. sudo systemctl daemon-reload
  9. sudo systemctl restart docker

  

阿里云安装docker 指定版本的更多相关文章

  1. 阿里云安装docker

    选centos6.5输入操作系统  yum install docker-io docker -d 提示没有备用IP地址可以用来桥接卡 接下来的网卡中编辑eth0 DEVICE=eth0 ONBOOT ...

  2. 彻底卸载干净docker并且安装docker 指定版本

    yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-la ...

  3. 阿里云 安装docker

    转  https://www.jianshu.com/p/f02d63ee98e0

  4. 如何安装NodeJS到阿里云Centos (64位版本V5-7)

    如何安装NodeJS到阿里云Centos (64位版本V5-7) (Centos与Red Hat® Enterprise Linux® / RHEL, Fedora属于一类) 1) 安装v0.10版 ...

  5. rancher说明为什么需要按照指定版本安装以及rancher和节点linux环境配置-docker指定版本安装

    rancher说明为什么需要按照指定版本安装以及rancher和节点linux环境配置-docker指定版本安装 待办 https://blog.csdn.net/CSDN_duomaomao/art ...

  6. 阿里云服务器安装Docker并部署nginx、jdk、redis、mysql

    阿里云服务器安装Docker并部署nginx.jdk.redis.mysql 一.安装Docker 1.安装Docker的依赖库 yum install -y yum-utils device-map ...

  7. 阿里云部署Docker(5)----管理和公布您的镜像

    出到这节,我在百度搜索了一下"阿里云部署Docker",突然发现怎么会有人跟我写的一样呢?哦,原来是其它博客系统的爬虫来抓取,然后也不会写转载自什么什么的.所以,我最终明确为什么那 ...

  8. 阿里云部署Docker(2)

    之前有一篇文章讲过在阿里云中安装Docker,相对来说那个是安装.可是安装完之后我们通常会碰到问题. 今天我给大家记录一下我的新的解决过程. 环境还是ubuntu12.04.如果我们已经把内核升级到了 ...

  9. 阿里云安装Nginx+vue项目部署

    阿里云安装Nginx+vue项目部署 nginx安装包下载 http://nginx.org/en/download.html nginx安装 首先先安装PCRE pcre-devel 和Zlib,因 ...

随机推荐

  1. 决策树归纳算法之ID3

    学习是一个循序渐进的过程,我们首先来认识一下,什么是决策树.顾名思义,决策树就是拿来对一个事物做决策,作判断.那如何判断呢?凭什么判断呢?都是值得我们去思考的问题. 请看以下两个简单例子: 第一个例子 ...

  2. sea.js常用接口

    seajs.config 用来对 Sea.js 进行配置. seajs.config({ // 指定需要使用的插件 plugins: ['text', 'shim'], // 设置别名,方便调用 al ...

  3. ASP.NET使用百度编辑器(UEditor)使用方法

    ASP.NET使用百度编辑器(UEditor)方法如下 第一步到百度官网下载百度编辑器 http://ueditor.baidu.com/website/download.html 下载.net版本 ...

  4. JSON类库 Flexjson学习

    官方地址(需FQ):http://flexjson.sourceforge.net/ Flexjson 是一个将 Java 对象转成 JSON 的 类库,是一个深度转换的过程. 下面是我写的一个例子: ...

  5. 题目1459:Prime ring problem(素数环问题——递归算法)

    题目链接:http://ac.jobdu.com/problem.php?pid=1459 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...

  6. 第二步 (仅供参考) sencha touch + PhoneGap(cordova 2.9 及其以下版本) 使用 adt eclipse进行打包

    首先你得安装一个adt-eclipse 参考资料 http://www.crifan.com/android_eclipse_offline_install_adt/ 然后就可以运行adt-eclip ...

  7. Sphinx以及coreseek的安装及使用

    检索结构 php -> sphinx -> mysql 非结构化数据又叫全文数据,非固定长度字段例如文章标题搜索这类适用sphinx 全文数据搜索: 1 顺序扫描 : 如like查找 2 ...

  8. apktool反解apk包

    APKTool APKTOOL是解包 APK 文件最常用的工具,许多 APK 工具箱都集成了 apktool.它可以完整解包 APK,解包后你可以看到 APK 里面的声明文件.布局文件.图片资源文件. ...

  9. 23种设计模式之抽象工厂(Abstract Factory)

    抽象工厂模式又称为Kit模式,属于对象创建型模式.抽象工厂模式是所有形式的工厂模式中最为抽象和最具一般性的一种形态,它提供了一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类.在抽象工厂模 ...

  10. iOS中self.xxx 和 _xxx 下划线的区别

    property (nonatomic,copy) NSString *propertyName; self.propertyName 是对属性的拜访: _propertyName 是对部分变量的拜访 ...