第八節(jié).Docker-ce自動安裝腳本

系統(tǒng)環(huán)境Centos7最小化安裝,配置靜態(tài)IP可以PING通外網(wǎng),DNS未配置

#!/bin/bash

#############################################################################
function shutdown_selinux_firewalld(){
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
    cat /etc/selinux/config|grep =|grep disabled
    sed -i '/$/a\nameserver 114.114.114.114\nnameserver 221.228.255.1' /etc/resolv.conf
    ping -c 4 www.baidu.com
    systemctl stop firewalld
    systemctl disable firewalld
    systemctl status firewalld
}
#############################################################################
#############################################################################
function change_yum_repo(){
    yum install -y yum-utils
    mkdir /etc/yum.repos.d/repod.bak
    mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/repod.bak
    cd /etc/yum.repos.d/
    yum-config-manager  --add-repo  http://mirrors.aliyun.com/repo/Centos-7.repo
    yum-config-manager  --add-repo  http://mirrors.163.com/.help/CentOS7-Base-163.repo
    yum-config-manager  --add-repo  http://mirrors.aliyun.com/repo/epel-7.repo
    yum-config-manager  --add-repo  https://download.docker.com/linux/centos/docker-ce.repo
    yum-config-manager  --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    yum clean all
    yum makecache
    yum list | grep epel-release
    yum install -y epel-release
    yum clean all
    yum makecache
    yum repolist enabled
    yum repolist all
    yum install -y tree vim  wget net-tools
}
#############################################################################
#############################################################################
function install_docker_ce(){
    yum remove docker docker-client docker-client-latest docker-common docker-latest  docker-latest-logrotate  docker-logrotate  docker-selinux  docker-engine-selinux docker-engine
    yum install -y device-mapper-persistent-data lvm2   
    yum install -y iptables-services
    systemctl enable iptables
    systemctl start iptables
    yum install docker-ce  -y
    systemctl enable docker
    systemctl start docker
    systemctl status iptables
    systemctl status docker
    echo -e "{\n\t\"registry-mirrors\": [ \"https://registry.docker-cn.com\" ]\n}" >/etc/docker/daemon.json  
    docker pull hello-world
    docker run hello-world
}   
##############################################################################
shutdown_selinux_firewalld
change_yum_repo
install_docker_ce

可以查看所有倉庫中所有docker版本,并選擇特定版本安裝

$ yum list docker-ce --showduplicates | sort -r
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容