From d3f7ee94163a45c806672a25ad54c18a1a79ace2 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Wed, 30 Dec 2020 15:38:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=89=E8=A3=85=E6=B5=81?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install_docker.sh | 73 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/install_docker.sh b/install_docker.sh index 999712c..34691d1 100644 --- a/install_docker.sh +++ b/install_docker.sh @@ -1,26 +1,63 @@ #!/bin/bash ##### CentOS 7安装Docker ##### -cd -mkdir temp -cd temp +function install_docker(){ + cd + mkdir temp + cd temp -#下载 -wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.3.9-3.1.el7.x86_64.rpm -wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-19.03.9-3.el7.x86_64.rpm -wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-19.03.9-3.el7.x86_64.rpm + #下载 + wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.3.9-3.1.el7.x86_64.rpm + wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-19.03.9-3.el7.x86_64.rpm + wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-19.03.9-3.el7.x86_64.rpm -#安装 -yum -y install containerd.io-1.3.9-3.1.el7.x86_64.rpm -yum -y install docker-ce-19.03.9-3.el7.x86_64.rpm -yum -y install docker-ce-cli-19.03.9-3.el7.x86_64.rpm + #安装 + yum -y install containerd.io-1.3.9-3.1.el7.x86_64.rpm + yum -y install docker-ce-19.03.9-3.el7.x86_64.rpm + yum -y install docker-ce-cli-19.03.9-3.el7.x86_64.rpm + #cd && rm -rf temp +} -#启动docker -systemctl start docker -#开机启动 -systemctl enable docker +#配置存储目录 +function set_storage() { + user add -g docker docker + mkdir -p /etc/docker + #创建配置文件 + touch /etc/docker/daemon.json + #创建存储目录 + mkdir -p /data/docker-data + chown -R docker:docker /data/docker-data +cat < /etc/docker/daemon.json +{ + "data-root": "/data/docker-data", + "storage-driver": "overlay2" +} +EOF +} +#install systemc +function install_systemd() { + cd && cd temp + wget -O docker.service +https://raw.githubusercontent.com/moby/moby/master/contrib/init/systemd/docker.service.rpm + mv docker.service /etc/systemd/system + systemctl daemon-reload + systemctl start docker + systemctl enable docker +} -echo '----------------------------------------' +#清理工作 +function clean_temp() { + cd && rm -rf temp +} -#运行一个hello word -docker run hello-world \ No newline at end of file +#测试运行 +function test_run() { + #运行一个hello word + docker run hello-world +} + +install_docker +set_storage +install_systemd +clean_temp +test_run