# 安装c++ 编译依赖
yum install-y gcc gcc-c++
1263720 * 2 + 225274421263720 * 2# 下载 包wget-c https://download.docker.com/linux/static/stable/x86_64/docker-20.10.21.tgz
# 解压tar-zxvf docker-20.10.21.tgz
# 改变权限 如果是root 用户就不需要chown root:root docker/*
# 复制到/usr/bin/目录 当然也可以自己配置环境变量cp-p docker/* /usr/bin/
# 创建用户组groupadddocker# 编写相关服务配置文件docker.service 、docker.socket、 containerd.service# vi docker.service[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 dockerExecStart=/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=65535LimitNPROC=65535LimitCORE=65535# Uncomment TasksMax if your systemd version supports it.# Only systemd 226 and above support this version.#TasksMax=infinityTimeoutStartSec=0# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes
# kill only the docker process, not all processes in the cgroupKillMode=process
# restart the docker process if it exits prematurelyRestart=on-failure
StartLimitBurst=3StartLimitInterval=60s
[Install]WantedBy=multi-user.target
# vi docker.socket[Unit]Description=Docker Socket for the API
PartOf=docker.service
[Socket]ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]WantedBy=sockets.target
# vi containerd.service[Unit]Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target
[Service]ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5# Having non-zero Limit*s causes performance problems due to accounting overhead# in the kernel. We recommend using cgroups to do container-local accounting.LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.# Only systemd 226 and above support this version.TasksMax=infinity
OOMScoreAdjust=-999
[Install]WantedBy=multi-user.target
# cp到/etc/systemd/system下面sudocp docker.socket /etc/systemd/system
sudocp docker.service /etc/systemd/system
sudocp containerd.service /etc/systemd/system
# 设置可执行权限chmod a+x /etc/systemd/system/docker.service
chmod a+x /etc/systemd/system/docker.socket
chmod a+x /etc/systemd/system/containerd.service
# 启动服务
systemctl start docker.service
# 设置开机自启动
systemctl enable docker.service