Browse Source

优化安装流程

master
xiaoz 4 years ago
parent
commit
d3f7ee9416
  1. 73
      install_docker.sh

73
install_docker.sh

@ -1,26 +1,63 @@
#!/bin/bash #!/bin/bash
##### CentOS 7安装Docker ##### ##### CentOS 7安装Docker #####
cd function install_docker(){
mkdir temp cd
cd temp 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/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-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/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 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-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 docker-ce-cli-19.03.9-3.el7.x86_64.rpm
#cd && rm -rf temp
}
#启动docker #配置存储目录
systemctl start docker function set_storage() {
#开机启动 user add -g docker docker
systemctl enable docker mkdir -p /etc/docker
#创建配置文件
touch /etc/docker/daemon.json
#创建存储目录
mkdir -p /data/docker-data
chown -R docker:docker /data/docker-data
cat <<EOF > /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 function test_run() {
#运行一个hello word
docker run hello-world
}
install_docker
set_storage
install_systemd
clean_temp
test_run

Loading…
Cancel
Save