此教程目前仅限于v1.31以及以上版本,低版本可能存在其他兼容问题
目前最新版本:v1.32
欢迎使用nuoyis-lnp docker版部署你的博客,使用该docker程序能快速部署你的网站或者博客系统
nuoyis-lnp优点
快,docker-compose up -d 就可部署完毕
稳定,nuoyis特有的健康检查方法,对不健康容器进行自动重启
防黑,nuoyis特有的版本号抹除,对黑客有一定的干扰性
弹性升级,nuoyis后续切换版本仅需在docker-compose内快速切换,快速回滚(docker特性)
docker部署方法
拉取docker指令
docker pull swr.cn-north-4.myhuaweicloud.com/nuoyis/nuoyis-lnp:v1.32
docker pull mariadb:latest
docker pull willfarrell/autoheal
docker 运行
docker network create --subnet=192.168.223.0/24 --gateway=192.168.223.1 nuoyis-net
docker run -d \
--name nuoyis-lnmp-np \
--network nuoyis-net \
--network-alias nuoyis-lnp \
-p 80:80 \
-p 443:443 \
-v /nuoyis-web/nginx/conf:/nuoyis-web/nginx/conf \
-v /nuoyis-web/nginx/webside:/nuoyis-web/nginx/webside \
-v /nuoyis-web/nginx/ssl:/nuoyis-web/nginx/ssl \
--health-cmd="curl -f http://localhost || exit 1" \
--health-interval=30s \
--health-retries=3 \
--health-start-period=10s \
--health-timeout=10s \
--restart always \
swr.cn-north-4.myhuaweicloud.com/nuoyis/nuoyis-lnp:v1.32
docker run -d \
--name nuoyis-lnmp-mariadb \
--network nuoyis-net \
--network-alias nuoyis-mariadb \
-e TIME_ZONE=Asia/Shanghai \
-e MYSQL_ROOT_PASSWORD="" \
-v /nuoyis-web/mariadb/init/init.sql:/docker-entrypoint-initdb.d/init.sql \
-v /nuoyis-web/mariadb/server:/var/lib/mysql \
-v /nuoyis-web/mariadb/import:/nuoyis-web/mariadb/import \
-v /nuoyis-web/mariadb/config/my.cnf:/etc/mysql/my.cnf \
-p 3306:3306 \
--health-cmd="sh -c 'mariadb -u root -p$$MYSQL_ROOT_PASSWORD -e \"SELECT 1 FROM information_schema.tables LIMIT 1;\"'" \
--health-interval=30s \
--health-retries=3 \
--health-start-period=10s \
--health-timeout=10s \
--restart always \
mariadb:latest
docker run -d \
--name nuoyis-lnmp-autoheal \
--network nuoyis-net \
-e AUTOHEAL_CONTAINER_LABEL=all \
-v /var/run/docker.sock:/var/run/docker.sock \
--restart always \
willfarrell/autoheal
docker-compose部署方法(需要自行设置mariadb root密码)
docker-compose.yaml
version: '2.32.2'
services:
nuoyis-lnmp-np:
container_name: nuoyis-lnmp-np
image: swr.cn-north-4.myhuaweicloud.com/nuoyis/nuoyis-lnp:v1.32
networks:
nuoyis-net:
aliases:
- nuoyis-lnp
ports:
- 80:80
- 443:443
volumes:
- /nuoyis-web/nginx/conf:/nuoyis-web/nginx/conf
- /nuoyis-web/nginx/webside:/nuoyis-web/nginx/webside
- /nuoyis-web/nginx/ssl:/nuoyis-web/nginx/ssl
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 30s
retries: 3
start_period: 10s
timeout: 10s
restart: always
nuoyis-lnmp-mariadb:
container_name: nuoyis-lnmp-mariadb
image: mariadb:latest
networks:
nuoyis-net:
aliases:
- nuoyis-mariadb
environment:
TIME_ZONE: Asia/Shanghai
MYSQL_ROOT_PASSWORD: ""
volumes:
- /nuoyis-web/mariadb/init/init.sql:/docker-entrypoint-initdb.d/init.sql
- /nuoyis-web/mariadb/server:/var/lib/mysql
- /nuoyis-web/mariadb/import:/nuoyis-web/mariadb/import
- /nuoyis-web/mariadb/config/my.cnf:/etc/mysql/my.cnf
ports:
- 3306:3306
healthcheck:
test: ["CMD", "sh", "-c", "mariadb -u root -p$$MYSQL_ROOT_PASSWORD -e 'SELECT 1 FROM information_schema.tables LIMIT 1;'"]
interval: 30s
retries: 3
start_period: 10s
timeout: 10s
restart: always
nuoyis-lnmp-autoheal:
container_name: nuoyis-lnmp-autoheal
image: willfarrell/autoheal
environment:
- AUTOHEAL_CONTAINER_LABEL=all
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: always
networks:
nuoyis-net:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.223.0/24
gateway: 192.168.223.1