docker部署
docker离线下载地址:https://download.docker.com/linux/static/stable/x86_64/
创建docker系统配置文件
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
创建安装启动脚本
#!/bin/sh
tar -zxvf $1
cp docker/* /usr/bin/
cp docker.service /etc/systemd/system/
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
systemctl enable docker.service
docker -v
卸载脚本
#!/bin/sh
rm -f /etc/systemd/system/docker.service
rm -rf /usr/bin/docker*
systemctl daemon-reload
具体目录
安装
./install.sh docker-19.03.9.tgz
#检查是否安装成功
docker ps
docker-compose 部署
下载包
https://github.com/docker/compose/releases
具体目录
安装
#!/bin/sh
#'复制docker-compose到执行目录/usr/local/bin下'
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
#'给予执行权限'
chmod +x /usr/local/bin/docker-compose
#'查看版本信息'
docker-compose -v
执行后结果 看到版本号即安装成功
/etc/docker/daemon.json 示例
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn","https://registry.docker-cn.com","https://hub-mirror.c.163.com"],
"insecure-registries": [
"172.16.11.13"
],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver":"json-file",
"log-opts": {"max-size":"50m", "max-file":"2"}
}