|
|
|
@ -1,6 +1,7 @@
@@ -1,6 +1,7 @@
|
|
|
|
|
#!/bin/bash |
|
|
|
|
##### CentOS 7安装Docker ##### |
|
|
|
|
|
|
|
|
|
function install_docker(){ |
|
|
|
|
cd |
|
|
|
|
mkdir temp |
|
|
|
|
cd temp |
|
|
|
@ -14,13 +15,49 @@ wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce
@@ -14,13 +15,49 @@ wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce
|
|
|
|
|
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 |
|
|
|
|
#配置存储目录 |
|
|
|
|
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 <<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 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#测试运行 |
|
|
|
|
function test_run() { |
|
|
|
|
#运行一个hello word |
|
|
|
|
docker run hello-world |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
install_docker |
|
|
|
|
set_storage |
|
|
|
|
install_systemd |
|
|
|
|
clean_temp |
|
|
|
|
test_run |
|
|
|
|