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
相关推荐
“码”力全开29 分钟前
【架构深探】基于Docker与GB28181/RTSP的边缘计算AI视频管理平台:异构算力调度与源码交付实践
人工智能·docker·架构
月巴月巴白勺合鸟月半33 分钟前
在Linux下开发桌面程序
linux·运维·服务器
zh路西法34 分钟前
【tmux入门】终端分屏、SSH远程守护与一键启动脚本
linux·运维·ssh·bash
qq_1631357540 分钟前
Linux 【03-pwd命令超详细教程】
linux
学途路漫漫40 分钟前
Ubuntu 24.04 国内网络环境全面优化指南
linux·网络·ubuntu
c2385641 分钟前
GDB 进程概念详解(下篇)—— 多进程与进阶调试能力
linux·服务器·数据库
RisunJan43 分钟前
Linux命令-php(PHP语言的命令行接口)
linux·php
A_humble_scholar1 小时前
Linux(八) 进程内存全景:环境变量、main 函数参数与虚拟地址空间全链路深度解析
linux·运维·服务器
longforus1 小时前
linux上播放音乐的终极解决方案
linux·音频·折腾
xcLeigh1 小时前
鸿蒙PC平台 Shotwell 照片管理器适配实战:从 Linux GNOME 到 鸿蒙PC 的 Electron 迁移
linux·electron·harmonyos·鸿蒙·shotwell·照片管理器