version: "3"services:
nginx:
image: nginx:1.21.4
#restart: always
container_name: nginx
volumes:
- "/etc/nginx/nginx.conf:/etc/nginx/nginx.conf"
- "/www/website:/usr/share/nginx/html"
- "/usr/local/ngix/logs:/var/log/nginx"
ports:
- "80:80"
depends_on:
- php
- mysql
- redis
- rabbitmq
networks:
docker_composer_net:
aliases:
- nginx
php:
image: php:7.4-fpm
ports:
- "9000:9000"
container_name: php
volumes:
- "/www/website:/usr/share/nginx/html"
networks:
docker_composer_net:
aliases:
- php
mysql:
image: mysql:5.7
ports:
- "3306:33060"
container_name: mysql
volumes:
- "/usr/local/mysql:/etc/mysql/conf.d"
environment:
- MYSQL_ROOT_PASSWORD=root
networks:
docker_composer_net:
aliases:
- mysql
redis:
image: redis
ports:
- "6379:6379"
container_name: redis
volumes:
- "/usr/local/redis/redis.conf:/usr/local/etc/redis/redis.conf"
command:
#两个写入操作 只是为了解决启动后警告 可以去掉
/bin/bash -c "echo 511 > /proc/sys/net/core/somaxconn
&& echo never > /sys/kernel/mm/transparent_hugepage/enabled
&& redis-server /usr/local/etc/redis/redis.conf"
networks:
docker_composer_net:
aliases:
- redis
rabbitmq:
image: rabbitmq:3.8.3-management
ports:
- "15672:15672"
- "5672:5672"
container_name: rabbitmq
volumes:
- "./data:/var/lib/rabbitmq"
environment:
- RABBITMQ_DEFAULT_USER=root
- RABBITMQ_DEFAULT_PASS=root
networks:
docker_composer_net:
aliases:
- rabbitmqnetworks:
docker_composer_net:
【docker|docker-compose 安装nginx、php、redis、mysql】
推荐阅读
- mysql|Docker安装mysql、redis、nginx
- Docker-Compose 部署Gitlab
- 前端性能优化|前端性能优化--减少首屏加载时间--gzip压缩
- 项目优化|前端项目首屏加载优化--页面初始进来加载速度慢的解决方案
- 云原生与微服务|【docker基础操作命令】(一)启动命令和镜像命令
- docker部署开源堡垒机
- 使用X-Content-Type-Options在Apache和Nginx中保护MIME类型
- Nginx Web服务器安全性和强化指南
- 如何在Nginx中实现ModSecurity OWASP核心规则集