docker+容器+redis+minio+java jar,实现开机自启动

一、docker

cpp 复制代码
systemctl enable docker.service

二、容器

加参数:--restart=always

如果容器已存在,修改容器:

cs 复制代码
docker update --restart=always 容器ID(或者容器名)

三、redis

1.注册服务

cs 复制代码
 vi /etc/systemd/system/redis.service

2.服务配置文件

cs 复制代码
[Unit]
Description=redis-server
After=network.target
 
[Service]
Type=forking
ExecStart=/usr/local/redis/redis-5.0.7/src/redis-server /usr/local/redis/redis-5.0.7/redis.conf
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target

3.服务自启动

cs 复制代码
 systemctl enable redis

四、minio

1.minio配置文件,配置用户名和密码

cs 复制代码
vi /home/minio/conf/minio.conf

输入内容:

cs 复制代码
MINIO_ACCESS_KEY="minioadmin"
MINIO_SECRET_KEY="Aa123456@admin"

2.注册服务

cs 复制代码
vi /etc/systemd/system/minio.service

3.服务配置文件

cs 复制代码
 [Unit]
Description=Minio
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
[Service]
# User and group
User=root
Group=root
EnvironmentFile=/home/minio/conf/minio.conf
ExecStart=/usr/local/soft/minio server --address :9000 --console-address :9090 /home/minio/data
ExecReload=/bin/kill -HUP $MAINPID
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
TimeoutStopSec=5
SendSIGKILL=no

[Install]
WantedBy=multi-user.target

4.服务自启动

cs 复制代码
 systemctl enable minio

五、java jar

1.注册服务

cs 复制代码
 vi /etc/systemd/system/exam.service

2.服务配置文件:

cs 复制代码
[Unit]
Description=exam
After=network.target
 
[Service]
User=root
Type=simple
ExecStart=/usr/local/java/jdk1.8.0_341/bin/java -jar  /home/app/exam/backend/exam.jar
Restart=on-failure
 
[Install]
WantedBy=multi-user.target

3.服务自启动

cs 复制代码
 systemctl enable exam
相关推荐
Libby博仙11 分钟前
docker 改了镜像源为阿里云,还是下载失败
阿里云·docker·容器
网络安全(华哥)1 小时前
网络安全服务实施流程管理 网络安全服务体系
运维·服务器·网络
致奋斗的我们1 小时前
Nginx反向代理及负载均衡
linux·运维·mysql·nginx·负载均衡·shell·openeluer
百锦再1 小时前
在Linux上创建一个Docker容器并在其中执行Python脚本
linux·python·docker
Ares-Wang1 小时前
负载均衡 方式
运维·负载均衡
钗头风1 小时前
3.Docker常用命令
运维·docker·容器
朝九晚五ฺ2 小时前
【Linux探索学习】第三十弹——线程互斥与同步(上):深入理解线程保证安全的机制
linux·运维·学习
不要吃栗子李2 小时前
高级运维:1. 对比 LVS 负载均衡群集的 NAT 模式和 DR 模式,比较其各自的优势 。2. 基于 openEuler 构建 LVS-DR 群集。
运维·负载均衡·lvs
ITPUB-微风2 小时前
网易严选DevOps实践:从传统到云原生的演进
运维·云原生·devops
圣心4 小时前
Ollama Docker 镜像部署
运维·docker·容器