• docker 安装


     Centos 7.X 安装docker 

     1 #!/bin/bash 
     2 
     3 # 成功输出
     4 success_echo(){
     5     echo -en "33[40;32m ########################### 33[0m
    "
     6     echo -en "33[40;32m ${1} 33[0m
    "
     7     echo -en "33[40;32m ########################### 33[0m
    "
     8 }
     9 
    10 # 错误输出
    11 error_echo(){
    12     echo -en "33[40;31m ########################### 33[0m
    "
    13     echo -en "33[40;31m ${1} 33[0m
    "
    14     echo -en "33[40;31m ########################### 33[0m
    "
    15 }
    16 
    17 function install_docker_server(){
    18   yum -y install yum-utils
    19   yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    20   # 安装docker-ce
    21   /usr/bin/yum  -y install  docker-ce-${1}
    22   # 更新docker 配置
    23   if [ -f /usr/lib/systemd/system/docker.service ];then
    24     /usr/bin/sed -i 's#^ExecStart=.*#ExecStart=/usr/bin/dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -g /opt/docker -s devicemapper  --storage-opt dm.fs=xfs --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.basesize=5G#g' /usr/lib/systemd/system/docker.service
    25   else
    26     error_echo "docker server install failure"
    27   fi
    28   # 设置docker 开机自启动
    29   /usr/bin/systemctl enable docker
    30   # 启动docker 服务
    31   /usr/bin/systemctl start docker
    32 }
    33 
    34 
    35 # 安装docker-compose命令
    36 install_docker_compose(){
    37    # 检查是否安装pip 
    38    if [ ! -f /usr/bin/pip ];then
    39    # install python-pip 
    40         /usr/bin/yum -y install epel-release python-devel python-pip
    41    fi
    42    # install docker-compose
    43    if [ -f /bin/docker-compose ];then
    44       success_echo "Docker-compose is already installed"
    45    else
    46       /usr/bin/pip install docker-compose &&  success_echo "docker-compose install success"
    47    fi
    48 }
    49 
    50 # 安装docker-enter命令
    51 install_docker_enter(){
    52    # install  docker-enter
    53    which docker-enter
    54    if [ $? -eq 0 ];then
    55       success_echo "Docker-enter is already installed"
    56    else
    57       /usr/bin/docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter &&    success_echo "docker-enter install success"
    58    fi
    59 }
    60 
    61 main(){
    62   DOCKER_VERSION=18.09.3
    63   # 安装docker
    64   install_docker_server ${DOCKER_VERSION}
    65   # 安装 docker-compose
    66   install_docker_compose
    67   # 安装 docker-enter
    68   install_docker_enter
    69 }
    70 
    71 main

      

      

  • 相关阅读:
    Ruby入门——简介&基本概述
    Ruby入门——数组
    测试之路——现阶段&下一阶段
    Ruby入门——环境准备
    Ruby入门——哈希表
    Linux常用命令<按字母排序...>之D,E,F
    多态界面的子控件控制
    随笔
    多态界面的数据显示
    app开发快速理解——webview网页显示
  • 原文地址:https://www.cnblogs.com/lmx1002/p/9475007.html
Copyright © 2020-2023  润新知