编写一个部署nginx,minio,redis,nacos,mysql的docker-compose详细配置脚本
时间: 2023-11-25 10:07:10 浏览: 118
好的,以下是一个部署nginx,minio,redis,nacos,mysql的docker-compose详细配置脚本:
```
version: "3.7"
services:
nginx:
image: nginx:latest
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- minio
- nacos
minio:
image: minio/minio:latest
environment:
MINIO_ACCESS_KEY: access_key
MINIO_SECRET_KEY: secret_key
volumes:
- ./data:/data
ports:
- "9000:9000"
command: server /data
depends_on:
- redis
redis:
image: redis:latest
ports:
- "6379:6379"
nacos:
image: nacos/nacos-server:latest
ports:
- "8848:8848"
environment:
MODE: standalone
mysql:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: database
MYSQL_USER: user
MYSQL_PASSWORD: password
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
```
注意替换掉 `MINIO_ACCESS_KEY`、`MINIO_SECRET_KEY`、`MYSQL_ROOT_PASSWORD`、`MYSQL_DATABASE`、`MYSQL_USER`、`MYSQL_PASSWORD` 等环境变量的值为你需要的值。
此外,还需要在同级目录下创建一个名为 `nginx.conf` 的 Nginx 配置文件,示例如下:
```
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://minio:9000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
```
同样需要替换 `server_name` 为你的域名。
最后,在命令行中进入到该 `docker-compose.yml` 文件所在的目录,运行 `docker-compose up` 命令即可启动所有服务。
阅读全文