|
@@ -12,8 +12,8 @@ version: "3.9"
|
|
|
# mkdir -p /opt/mysql/{data,config} /opt/mysql-files
|
|
|
# chmod -R 777 /opt/mysql
|
|
|
|
|
|
-# 2.拷贝 my.cnf 配置文件
|
|
|
-# 第一次启动,不要带 my.cnf 映射,要先把 my.cnf 文件拷出来
|
|
|
+# 拷贝 my.cnf 配置文件 (MySQL)
|
|
|
+# * 首次启动,不要带 my.cnf 映射,要先把 my.cnf 文件拷出来
|
|
|
# docker cp mysql8:/etc/mysql/my.cnf /opt/mysql/config
|
|
|
# chmod 644 /opt/mysql/config/my.cnf
|
|
|
# (保证 my.cnf 必须是文件,不是目录)
|
|
@@ -23,12 +23,17 @@ version: "3.9"
|
|
|
# chmod -R 777 /opt/redis
|
|
|
|
|
|
# 4.首次启动前创建(Nginx)
|
|
|
-# mkdir -p /etc/nginx/conf.d
|
|
|
-# mkdir -p /etc/nginx/www/html
|
|
|
-# mkdir -p /etc/nginx/log
|
|
|
+# mkdir -p /opt/nginx/{www,log}
|
|
|
+# chmod -R 777 /opt/nginx
|
|
|
+
|
|
|
+# 拷贝 nginx.conf 配置文件 (Nginx)
|
|
|
+# docker cp nginx:/etc/nginx/conf.d /opt/nginx
|
|
|
+# docker cp nginx:/etc/nginx/nginx.conf /opt/nginx/nginx.conf
|
|
|
+# docker cp nginx:/usr/share/nginx/html /opt/nginx/www/html
|
|
|
# -------------------------------------
|
|
|
|
|
|
services:
|
|
|
+
|
|
|
# -- MySQL8.0 -----------------------
|
|
|
mysql8:
|
|
|
image: mysql:8.0.23
|
|
@@ -40,11 +45,13 @@ services:
|
|
|
- "3306:3306"
|
|
|
volumes:
|
|
|
- /opt/mysql/data:/var/lib/mysql
|
|
|
+ # 首次复制 (docker cp)
|
|
|
# - /opt/mysql/config/my.cnf:/etc/mysql/my.cnf:ro
|
|
|
- /opt/mysql-files:/var/lib/mysql-files
|
|
|
command:
|
|
|
- mysqld
|
|
|
- --sql-mode=STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
|
|
|
+
|
|
|
# -- Redis6.2 -----------------------
|
|
|
redis:
|
|
|
image: redis:6.2 # 官方完整版,非 Alpine
|
|
@@ -65,6 +72,7 @@ services:
|
|
|
--appendonly yes
|
|
|
--loglevel warning
|
|
|
--logfile /logs/redis.log
|
|
|
+
|
|
|
# -- Nginx --------------------------
|
|
|
nginx:
|
|
|
image: nginx:1.26.3
|
|
@@ -74,9 +82,10 @@ services:
|
|
|
- "80:80"
|
|
|
- "443:443"
|
|
|
volumes:
|
|
|
- - /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
|
- - /etc/nginx/conf.d:/etc/nginx/conf.d:ro
|
|
|
- - /etc/nginx/www/html:/usr/share/nginx/html:ro
|
|
|
- - /etc/nginx/log:/var/log/nginx
|
|
|
+ # 首次复制 (docker cp)
|
|
|
+ # - /opt/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
|
+ # - /opt/nginx/www/html:/usr/share/nginx/html:ro
|
|
|
+ # - /opt/nginx/conf.d:/etc/nginx/conf.d:ro
|
|
|
+ - /opt/nginx/log:/var/log/nginx
|
|
|
environment:
|
|
|
- TZ=UTC
|