[root@localhost php]
/data
├── docker-compose.yml
├── nginx
│ ├── conf.d
│ │ └── default.conf
│ └── log
│ ├── access.log
│ └── error.log
├── php
│ ├── conf.d
│ │ └── php.ini
│ └── Dockerfile
└── www
├── index.html
└── index.php
[root@localhost php]
FROM php:7.4.28-fpm
MAINTAINER 3539949703@qq.com
RUN docker-php-ext-install pdo pdo_mysql mysqli \
&& pecl install redis-4.2.0 && docker-php-ext-enable redis
version: "3"
services:
nginx:
image: nginx:latest
container_name: "compose-nginx"
restart: always
ports:
- "80:80"
- "443:443"
environment:
- TZ=Asia/Shanghai
depends_on:
- "php"
- "mysql"
- "redis"
volumes:
- "/data/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf"
- "/data/nginx/log:/var/log/nginx"
- "/data/www:/usr/share/nginx/www"
networks:
- net-app
php:
image: "/data/php"
container_name: "compose-php"
restart: always
ports:
- "9000:9000"
environment:
- TZ=Asia/Shanghai
volumes:
- "/data/www:/usr/share/nginx/www"
- "/data/php/conf.d/php.ini:/usr/local/etc/php/php.ini"
networks:
- net-app
mysql:
image: mysql
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=123456
networks:
- net-app
container_name: "compose-mysql"
redis:
image: redis:latest
networks:
- net-app
container_name: "compose-redis"
networks:
net-app:
docker image inspect nginx:latest | grep -i version
注:这里只是展示compose构建Nginx+PHP+MySQL+Redis环境大概步骤
|