相关资料
@see https://zhuanlan.zhihu.com/p/504248808 @see
@see https://docs.halo.run/getting-started/install/docker-compose
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine \
docker-ce
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
sudo yum install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
systemctl enable docker.service
脚本清空(针对已经启动的所有docke容器日志文件)
#vim docker-clear.sh
内容如下:
#!/bin/sh
echo "======== start clean docker containers logs ========"
logs=$(find /var/lib/docker/containers/ -name *-json.log)
for log in $logs
do
echo "clean logs : $log"
cat /dev/null > $log
done
echo "======== end clean docker containers logs ========"
#设置权限并执行
# chmod +x docker-clear.sh
# ./docker-clear.sh
启动初始化(针对未启动的容器设置默认日志文件大小)
nginx:
image: nginx:1.12.1
restart: always
logging:
driver: “json-file”
options:
max-size: “5g”
全局设置(针对所有启动和未启动的日志文件大小)
vim /etc/docker/daemon.json //改设置不会删除容器
{
"registry-mirrors": ["http://f613ce8f.m.daocloud.io"],
"log-driver":"json-file",
"log-opts": {"max-size":"500m", "max-file":"3"}
}
// 重启docker守护进程
# systemctl daemon-reload
# systemctl restart docker
docker pull halohub/halo:2.2.0
docker run \
-it -d \
--name halo \
-p 8090:8090 \
-v ~/.halo2:/root/.halo2 \
halohub/halo:2.2.0 \
--halo.external-url=http://ip:8080/ \
--halo.security.initializer.superadminuser=admin \
--halo.security.initializer.superadminpassword=P@88w0rd \
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.3.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose -v
cd ~/halo
touch docker-compose.yaml
version: "3"
services:
halo:
image: halohub/halo:2.2.0
container_name: halo
restart: on-failure:3
depends_on:
halodb:
condition: service_healthy
networks:
halo_network:
volumes:
- ./:/root/.halo2
ports:
- "8080:8080"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health/readiness"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
command:
- --spring.r2dbc.url=r2dbc:pool:mysql://halodb:port/dbname
- --spring.r2dbc.username=root
# MySQL 的密码,请保证与下方 MYSQL_ROOT_PASSWORD 的变量值一致。
- --spring.r2dbc.password=password
- --spring.sql.init.platform=mysql
# 外部访问地址,请根据实际需要修改
- --halo.external-url=http://localhost:8080/
# 初始化的超级管理员用户名
- --halo.security.initializer.superadminusername=admin
# 初始化的超级管理员密码
- --halo.security.initializer.superadminpassword=P@88w0rd
halodb:
image: mysql:8.0.31
container_name: halodb
restart: on-failure:3
networks:
halo_network:
command:
- --default-authentication-plugin=mysql_native_password
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_general_ci
- --explicit_defaults_for_timestamp=true
volumes:
- ./mysql:/var/lib/mysql
- ./mysqlBackup:/data/mysqlBackup
ports:
- "3306:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
interval: 3s
retries: 5
start_period: 30s
environment:
# 请修改此密码,并对应修改上方 Halo 服务的 SPRING_R2DBC_PASSWORD 变量值
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=halo
networks:
halo_network:
docker-compose up -d //自动拉取halo和mysql镜像并执行halo容器构建及项目启动
docker-compose logs -f //查看启动日志
docker-compose down //关闭并删除容器
cp -r ~/halo ~/halo.archive //备份数据
//项目更换版本
1、修改配置文件halo版本
2、docker-compose down
3、docker-compose up -d