docker源码安装,附一键部署脚本

2022/7/27 1:23:49

本文主要是介绍docker源码安装,附一键部署脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

一、下载源码包

下载地址:https://download.docker.com/linux/static/stable/x86_64/

mkdir -p /opt/src && cd /opt/src
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.17.tgz

二、安装docker

tar -xf docker-20.10.17.tgz
cp docker/* /usr/bin

三、创建配置文件

mkdir /etc/docker
 
## 配置国内的镜像源,加速镜像拉取
cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"]
}
EOF

四、systemd管理docker

1、生成配置文件

cat > /usr/lib/systemd/system/docker.service << EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF
2、启动并设置开机自启
systemctl daemon-reload
systemctl start docker
systemctl enable docker
docker --version

五、附上一键安装脚本 

## 下载安装包,可自行调整版本
mkdir -p /opt/src && cd /opt/src
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.17.tgz
## 安装docker
tar -xf docker-20.10.17.tgz
cp docker/* /usr/bin
## 创建配置文件
mkdir /etc/docker
 
## 配置国内的镜像源,加速镜像拉取
cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"]
}
EOF
## 生成systemd配置文件
cat > /usr/lib/systemd/system/docker.service << EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF
## 启动并设置开启自启
systemctl daemon-reload
systemctl start docker
systemctl enable docker
docker --version

 



这篇关于docker源码安装,附一键部署脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程