linux 一键安装docker docker-compose

shell 复制代码
# 环境 deploy.sh  docker-19.03.9.tgz  docker-compose-linux-x86_64
tar -zxvf docker-19.03.9.tgz
mv docker-19.03.9 docker
cp docker/* /usr/bin/
touch /etc/systemd/system/docker.service
cat << EOG > /etc/systemd/system/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 docker
ExecStart=/usr/bin/dockerd --selinux-enabled=false
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
EOG
#给docker.service文件添加执行权限
chmod +x /etc/systemd/system/docker.service
#重新加载配置文件(每次有修改docker.service文件时都要重新加载下)
systemctl daemon-reload   
#启动docker
systemctl start docker
设置开机启动
#systemctl enable docker.service
#查看docker服务状态
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose -v
systemctl status docker
相关推荐
无足鸟ICT6 分钟前
【RHCA+】bash命令
linux·开发语言·bash
weixin_3077791314 分钟前
Linux下Docker Compose里运行的MySQL数据库故障诊断Shell脚本
linux·运维·mysql·docker·自动化
小生不才yz19 分钟前
Shell脚本精读 · S14-02 | 脚本模板:从 20 行工具到可维护项目
linux
x-cmd34 分钟前
Linus 9 年前说「模糊测试有效」——今天已成 OSS-Fuzz 时代铁律
linux·ai·rust·开源·自动化·agent·安全性测试
六点_dn2 小时前
Linux学习笔记-chmod命令
linux·笔记·学习
AOwhisky2 小时前
Python 基础语法(上篇 + 下篇)——综合自测题
linux·windows·python
浮江雾2 小时前
Flutter第四节------核心概念学习笔记:从基础语法到异步编程
linux·服务器·开发语言·笔记·flutter·入门·基础
FoldWinCard2 小时前
D4 Linux 进程 内存 等命令
linux·运维·服务器
nuo5342022 小时前
基础 3 —— Docker 的常用命令
docker·容器
在线OJ的阿川2 小时前
仿muduo库实现高并发服务器
linux·服务器·c++