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
相关推荐
HIT_Weston10 小时前
93、【Ubuntu】【Hugo】搭建私人博客:面包屑(一)
linux·运维·ubuntu
唯情于酒10 小时前
Docker学习
学习·docker·容器
cuijiecheng201811 小时前
Linux下Beyond Compare过期
linux·运维·服务器
喵叔哟11 小时前
20.部署与运维
运维·docker·容器·.net
HIT_Weston11 小时前
92、【Ubuntu】【Hugo】搭建私人博客:侧边导航栏(六)
linux·运维·ubuntu
CodeAllen嵌入式11 小时前
Windows 11 本地安装 WSL 支持 Ubuntu 24.04 完整指南
linux·运维·ubuntu
德育处主任14 小时前
『NAS』在群晖部署一个文件加密工具-hat.sh
前端·算法·docker
RisunJan14 小时前
Linux命令-ipcs命令(报告进程间通信(IPC)设施状态的实用工具)
linux·运维·服务器
HABuo15 小时前
【Linux进程(四)】进程切换&环境变量深入剖析
linux·运维·服务器·c语言·c++·ubuntu·centos