1. 基于阿里云安装:
    1. #!/bin/bash
    2. #安装依赖的软件
    3. yum install -y yum-utils device-mapper-persistent-data lvm2
    4. #添加yum源
    5. yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    6. #更新并安装docker
    7. yum makecache fast
    8. yum -y install docker-ce
    1. 安装指定版本的Docker-CE:
    # Step 1: 查找Docker-CE的版本:
    # yum list docker-ce.x86_64 --showduplicates | sort -r
    # Step2 : 安装指定版本的Docker-CE: (VERSION 例如上面的 17.03.0.ce.1-1.el7.centos)
    # sudo yum -y install docker-ce-[VERSION]
    # 注意:在某些版本之后,docker-ce安装出现了其他依赖包,如果安装失败的话请关注错误信息。例如 docker-ce 17.03 之后,需要先安装 docker-ce-selinux。
    # yum list docker-ce-selinux- --showduplicates | sort -r
    # sudo yum -y install docker-ce-selinux-[VERSION]
    
    1. ubuntu安装:
    apt update
    apt install apt-transport-https ca-certificates curl software-properties-common
    curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
    add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
    apt-get update
    
    安装特定的版本的:
    apt-cache madison docker-ce
    apt-get install docker-ce=<VERSION>
    
    1. /etc/docker/daemon.json:

      cat > /etc/docker/daemon.json << EOF
      {
       "log-driver": "json-file",
       "log-opts": {
           "max-size": "100m"
       },
       "storage-driver": "overlay2",
       "storage-opts": [
           "overlay2.override_kernel_check = true"
       ],
       "registry-mirrors": ["https://4p5gxeik.mirror.aliyuncs.com"]
      }
      EOF
      
    2. 使用pip安装docker-compose

    yum -y install python-pip
    pip install --upgrade pip -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
    #安装python-devel
    yum -y install python-devel
    #安装开发组件
    yum -y groupinstall development
    #安装docker-compose
    pip install docker-compose -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
    #清理yum缓存
    yum clean all
    
    1. 下载安装包,安装docker-compose
    curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose
    docker-compose --version