mirror of https://github.com/helloxz/shell.git
xiaoz
4 years ago
1 changed files with 55 additions and 18 deletions
@ -1,26 +1,63 @@
@@ -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 <<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…
Reference in new issue