sh docker-install.sh 1.12.6    #ubuntu16.4 测试通过
#!/bin/sh
set -e
#
# This script is meant for quick & easy install via:
# 'curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh'
# or:
# 'wget -qO- http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh'
#
# For test builds (ie. release candidates):
# 'curl -fsSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/test/internet | sh'
# or:
# 'wget -qO- http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/test/internet | sh'
#
# For experimental builds:
# 'curl -fsSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/experimental/internet | sh'
# or:
# 'wget -qO- http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/experimental/internet | sh'
#
# Docker Maintainers:
# To update this script on https://get.docker.com,
# use hack/release.sh during a normal release,
# or the following one-liner for script hotfixes:
# aws s3 cp --acl public-read hack/install.sh s3://get.docker.com/index
# url="http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet"
apt_url="http://mirrors.aliyun.com/docker-engine/apt"
yum_url="http://mirrors.aliyun.com/docker-engine/yum"
gpg_fingerprint="58118E89F3A912897C070ADBF76221572C52609D" key_servers="
ha.pool.sks-keyservers.net
pgp.mit.edu
keyserver.ubuntu.com
" command_exists() {
command -v "$@" > /dev/null >&
} echo_docker_as_nonroot() {
if command_exists docker && [ -e /var/run/docker.sock ]; then
(
set -x
$sh_c 'docker version'
) || true
fi
your_user=your-user
[ "$user" != 'root' ] && your_user="$user"
# intentionally mixed spaces and tabs here -- tabs are stripped by "<<-EOF", spaces are kept in the output
cat <<-EOF If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like: sudo usermod -aG docker $your_user Remember that you will have to log out and back in for this to take effect! EOF
} # Check if this is a forked Linux distro
check_forked() { # Check for lsb_release command existence, it usually exists in forked distros
if command_exists lsb_release; then
# Check if the `-u` option is supported
set +e
lsb_release -a -u > /dev/null >&
lsb_release_exit_code=$?
set -e # Check if the command has exited successfully, it means we're in a forked distro
if [ "$lsb_release_exit_code" = "" ]; then
# Print info about current distro
cat <<-EOF
You're using '$lsb_dist' version '$dist_version'.
EOF # Get the upstream release info
d '[[:space:]]')
f | tr -d '[[:space:]]') # Print info about upstream distro
cat <<-EOF
Upstream release is '$lsb_dist' version '$dist_version'.
EOF
else
if [ -r /etc/debian_version ] && [ "$lsb_dist" != "ubuntu" ]; then
# We're Debian and don't even know it!
lsb_dist=debian
dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
case "$dist_version" in
|'Kali Linux 2')
dist_version="jessie"
;;
)
dist_version="wheezy"
;;
esac
fi
fi
fi
} rpm_import_repository_key() {
local key=$; shift
local tmpdir=$(mktemp -d)
chmod "$tmpdir"
for key_server in $key_servers ; do
gpg --homedir "$tmpdir" --keyserver "$key_server" --recv-keys "$key" && break
done
gpg --homedir "$tmpdir" -k "$key" >/dev/null
gpg --homedir "$tmpdir" --export --armor "$key" > "$tmpdir"/repo.key
rpm --import "$tmpdir"/repo.key
rm -rf "$tmpdir"
} semverParse() {
major="${1%%.*}"
minor="${1#$major.}"
minor="${minor%%.*}"
patch="${1#$major.$minor.}"
patch="${patch%%[-.]*}"
} do_install() {
case "$(uname -m)" in
*)
;;
*)
cat >& <<-'EOF'
Error: you are not using a 64bit platform.
Docker currently only supports 64bit platforms.
EOF
exit
;;
esac if command_exists docker; then
version="$(docker -v | awk -F '[ ,]+' '{ print $3 }')"
MAJOR_W=
MINOR_W= semverParse $version shouldWarn=
if [ $major -lt $MAJOR_W ]; then
shouldWarn=
fi if [ $major -le $MAJOR_W ] && [ $minor -lt $MINOR_W ]; then
shouldWarn=
fi cat >& <<-'EOF'
Warning: the "docker" command appears to already exist on this system. If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation. If you installed the current Docker package using this script and are using it
EOF if [ $shouldWarn -eq ]; then
cat >& <<-'EOF'
again to update Docker, we urge you to migrate your image store before upgrading
to v1.+. You can find instructions for this here:
https://github.com/docker/docker/wiki/Engine-v1.10.0-content-addressability-migration
EOF
else
cat >& <<-'EOF'
again to update Docker, you can safely ignore this message.
EOF
fi cat >& <<-'EOF' You may press Ctrl+C now to abort this script.
EOF
( set -x; sleep )
fi user="$(id -un 2>/dev/null || true)" sh_c='sh -c'
if [ "$user" != 'root' ]; then
if command_exists sudo; then
sh_c='sudo -E sh -c'
elif command_exists su; then
sh_c='su -c'
else
cat >& <<-'EOF'
Error: this installer needs the ability to run commands as root.
We are unable to find either "sudo" or "su" available to make this happen.
EOF
exit
fi
fi curl=''
if command_exists curl; then
curl='curl -sSL'
elif command_exists wget; then
curl='wget -qO-'
elif command_exists busybox && busybox --list-modules | grep -q wget; then
curl='busybox wget -qO-'
fi # check to see which repo they are trying to install from
if [ -z "$repo" ]; then
repo='main'
if [ "http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/test/internet" = "$url" ]; then
repo='testing'
then
repo='experimental'
fi
fi # perform some very rudimentary platform detection
lsb_dist=''
dist_version=''
if command_exists lsb_release; then
lsb_dist="$(lsb_release -si)"
fi
if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then
lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
fi
if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then
lsb_dist='debian'
fi
if [ -z "$lsb_dist" ] && [ -r /etc/fedora-release ]; then
lsb_dist='fedora'
fi
if [ -z "$lsb_dist" ] && [ -r /etc/oracle-release ]; then
lsb_dist='oracleserver'
fi
if [ -z "$lsb_dist" ]; then
if [ -r /etc/centos-release ] || [ -r /etc/redhat-release ]; then
lsb_dist='centos'
fi
fi
if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')" case "$lsb_dist" in ubuntu)
if command_exists lsb_release; then
dist_version="$(lsb_release --codename | cut -f2)"
fi
if [ -z "$dist_version" ] && [ -r /etc/lsb-release ]; then
dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")"
fi
;; debian)
dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
case "$dist_version" in
)
dist_version="jessie"
;;
)
dist_version="wheezy"
;;
esac
;; oracleserver)
# need to switch lsb_dist to match yum repo URL
lsb_dist="oraclelinux"
ed 's/\..*//' | sed 's/Server*//' | sort -r | head -)"
;; fedora|centos)
ed 's/\..*//' | sed 's/Server*//' | sort -r | head -)"
;; *)
if command_exists lsb_release; then
dist_version="$(lsb_release --codename | cut -f2)"
fi
if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
fi
;; esac # Check if this is a forked Linux distro
check_forked # Run setup for each distro accordingly
case "$lsb_dist" in
amzn)
(
set -x
$sh_c 'sleep 3; yum -y -q install docker'
)
echo_docker_as_nonroot
exit
;; 'opensuse project'|opensuse)
echo 'Going to perform the following operations:'
if [ "$repo" != 'main' ]; then
echo ' * add repository obs://Virtualization:containers'
fi
echo ' * install Docker'
$sh_c 'echo "Press CTRL-C to abort"; sleep 3' if [ "$repo" != 'main' ]; then
# install experimental packages from OBS://Virtualization:containers
(
set -x
zypper -n ar -f obs://Virtualization:containers Virtualization:containers
rpm_import_repository_key 55A0B34D49501BB7CA474F5AA193FBB572174FC2
)
fi
(
set -x
zypper -n install docker
)
echo_docker_as_nonroot
exit
;;
'suse linux'|sle[sd])
echo 'Going to perform the following operations:'
if [ "$repo" != 'main' ]; then
echo ' * add repository obs://Virtualization:containers'
echo ' * install experimental Docker using packages NOT supported by SUSE'
else
echo ' * add the "Containers" module'
echo ' * install Docker using packages supported by SUSE'
fi
$sh_c 'echo "Press CTRL-C to abort"; sleep 3' if [ "$repo" != 'main' ]; then
# install experimental packages from OBS://Virtualization:containers
by SUSE'
(
set -x
zypper -n ar -f obs://Virtualization:containers/SLE_12 Virtualization:containers
rpm_import_repository_key 55A0B34D49501BB7CA474F5AA193FBB572174FC2
)
else
# Add the containers module
# Note well-: the SLE machine must already be registered against SUSE Customer Center
# Note well-: the `-r ""` is required to workaround a known issue of SUSEConnect
(
set -x
SUSEConnect -p sle-module-containers//x86_64 -r ""
)
fi
(
set -x
zypper -n install docker
)
echo_docker_as_nonroot
exit
;; ubuntu|debian)
export DEBIAN_FRONTEND=noninteractive did_apt_get_update=
apt_get_update() {
if [ -z "$did_apt_get_update" ]; then
( set -x; $sh_c 'sleep 3; apt-get update || true' )
did_apt_get_update=
fi
} # aufs is preferred over devicemapper; try to ensure the driver is available.
if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
/dev/null; then
kern_extras="linux-image-extra-$(uname -r) linux-image-extra-virtual" apt_get_update
( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
echo >& 'Warning: tried to install '"$kern_extras"' (for AUFS)'
!'
( set -x; sleep )
fi
else
echo >& 'Warning: current kernel is not supported by the linux-image-extra-virtual'
echo >& ' package. We have no AUFS support. Consider installing the packages'
echo >& ' linux-image-virtual kernel and linux-image-extra-virtual for AUFS support.'
( set -x; sleep )
fi
fi # install apparmor utils if they're missing and apparmor is enabled in the kernel
# otherwise Docker will fail to start
if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then
if command -v apparmor_parser >/dev/null >&; then
echo 'apparmor is enabled in the kernel and apparmor utils were already installed'
else
echo 'apparmor is enabled in the kernel, but apparmor_parser missing'
apt_get_update
( set -x; $sh_c 'sleep 3; apt-get install -y -q apparmor' )
fi
fi if [ ! -e /usr/lib/apt/methods/https ]; then
apt_get_update
( set -x; $sh_c 'sleep 3; apt-get install -y -q apt-transport-https ca-certificates' )
fi
if [ -z "$curl" ]; then
apt_get_update
( set -x; $sh_c 'sleep 3; apt-get install -y -q curl ca-certificates' )
curl='curl -sSL'
fi
(
set -x
for key_server in $key_servers ; do
$sh_c "apt-key adv --keyserver hkp://${key_server}:80 --recv-keys ${gpg_fingerprint}" && break
done
$sh_c "apt-key adv -k ${gpg_fingerprint} >/dev/null"
$sh_c "mkdir -p /etc/apt/sources.list.d"
} > /etc/apt/sources.list.d/docker.list"
ker-engine; else apt-get install -y -q docker-engine=${docker_version}-~ubuntu-${dist_version}; fi"
)
echo_docker_as_nonroot
exit
;; fedora|centos|oraclelinux)
$sh_c "cat >/etc/yum.repos.d/docker-${repo}.repo" <<-EOF
[docker-${repo}-repo]
name=Docker ${repo} Repository
baseurl=${yum_url}/repo/${repo}/${lsb_dist}/${dist_version}
enabled=
gpgcheck=
gpgkey=${yum_url}/gpg
EOF
if [ "$lsb_dist" = "fedora" ] && [ "$dist_version" -ge "" ]; then
(
set -x
$sh_c 'sleep 3; dnf -y -q install docker-engine'
)
else
(
set -x
ll docker-engine; else yum -y -q install docker-engine-$docker_version; fi"
)
fi
echo_docker_as_nonroot
exit
;;
gentoo)
hen
in the output
cat >& <<-'EOF' You appear to be trying to install the latest nightly build in Gentoo.'
The portage tree should contain the latest stable release of Docker, but'
if you want something more recent, you can always use the live ebuild'
provided in the "docker" overlay available via layman. For more'
instructions, please see the following URL:' https://github.com/tianon/docker-overlay#using-this-overlay' After adding the "docker" overlay, you should be able to:' emerge -av =app-emulation/docker-' EOF
exit
fi (
set -x
$sh_c 'sleep 3; emerge app-emulation/docker'
)
exit
;;
esac # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-'EOF'", spaces are kept in the output
cat >& <<-'EOF' Either your platform is not easily detectable, is not supported by this
installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have
a package for Docker. Please visit the following URL for more detailed
installation instructions: https://docs.docker.com/engine/installation/ EOF
exit
} # wrapped up in a function so that we have some protection against only getting
# half the file during "curl | sh"
if [ ! -z $ ] ; then docker_version=$; fi do_install

代码

加速器

#!/bin/sh
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
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. Win7/Win8/IIS7/IIS8配置ASP/ACCESS

    1.在IIS信息服务管理器配置好站点后,配置ASP属性: a.IIS启用ASP 1.打开控制面板>>程序和功能>>“打开或关闭windows功能”,见下图 2.稍等片刻,出现一 ...

  2. 高性能Android应用开发

  3. call()、apply()和bind()的异同

    相同点: 改变this的指向: var a = { name:"丸子", fn:function(){ console.log(this.name); } } var b = a. ...

  4. 题目1454:Piggy-Bank(完全背包问题)

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

  5. LeetCode 12 Integer to Roman (整数转罗马数字)

    题目链接: https://leetcode.com/problems/integer-to-roman/?tab=Description   String M[] = {"", ...

  6. dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid

    这两个变量被设置了 DYLD_LIBRARY_PATH *或* LD_LIBRARY_PATH, 用下面的明令查找一下,一般在.bash_profile, .bashrc 等文件中.执行brew do ...

  7. 未能加载文件或程序集“XX.XXX.Web”或它的某一个依赖项。试图加载格式不正确的程序

    IIS应用程序池->右键高级设置->启用32位应用程序  设置为true

  8. linux系统下kvm虚拟机的安装

    一 KVM虚拟机简介 KVM是kernel-based Virtual Machine的简称,目前已成为学术界的主流VMM之一.KVM的虚拟化需要硬件支持(如Intel VT技术或者AMD V技术) ...

  9. [工具] Textify – 复制不可能的窗口内容[Win]

    Textify 是一款 Windows 下的小工具,能够复制那些平时无法复制的内容,比如错误提示.菜单按钮文字等等,只需要按下快捷键就可以随意复制,俗称复制不可能. http://rammichael ...

  10. Spring Cloud Eureka 配置

    实例名配置       在Netflix Eureka的原生实现中,实例名采用主机名作为默认值,这样的设置使得在同一主机上无法启动多个相同的实例,所以在Spring Cloud Eureka的配置中, ...