美文网首页
一键部署docker

一键部署docker

作者: 平凡的运维之路 | 来源:发表于2023-08-02 17:52 被阅读0次

    shell 一键部署docker

    • shell 安装 docker
    #! /bin/bash
    #One click deployment Docker
    
    remove_old_docker(){
        echo "yum remove docker old version"
        yum remove docker \
                 docker-client \
                 docker-client-latest \
                 docker-common \
                 docker-latest \
                 docker-latest-logrotate \
                 docker-logrotate \
                 docker-engine
    }
    
    init_install_docker(){
        sudo yum install -y yum-utils device-mapper-persistent-data lvm2
         
        sudo yum-config-manager --add-repo \
           https://download.docker.com/linux/centos/docker-ce.repo
    
        yum -y install docker-ce docker-ce-cli containerd.io
        
        base_docker_env
    }
    
    base_docker_env(){
        systemctl start docker && systemctl enable docker
         
        docker version 
          
        sudo systemctl daemon-reload
        sudo systemctl restart docker
    
        sudo mkdir -p /etc/docker
        sudo tee /etc/docker/daemon.json <<-'EOF'
        {
         "registry-mirrors": ["https://onl4ynrr.mirror.aliyuncs.com"]
        }
        EOF
        
        sudo systemctl daemon-reload
        sudo systemctl restart docker
        curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
        chmod +x /usr/local/bin/docker-compose
    }
    
    init_install_select_docker_version(){
        sudo yum install -y yum-utils device-mapper-persistent-data lvm2
         
        sudo yum-config-manager --add-repo \
           https://download.docker.com/linux/centos/docker-ce.repo
         
        yum list docker-ce --showduplicates | sort -r
         
        yum -y install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
        
        base_docker_env
    }
    
    remove_old_docker
    
    init_install_docker
    

    相关文章

      网友评论

          本文标题:一键部署docker

          本文链接:https://www.haomeiwen.com/subject/iaeppdtx.html