One minute
Docker 搭建 Lnmp 环境
docker 搭建 lnmp 环境
构建脚本:
php5.6 lnmp 环境 搭建 yml
# docker version: 18.06.0+
# docker-compose version: 1.23.2+
# OpenSSL version: OpenSSL 1.1.0h
version: "3.7"
services:
web:
image: nginx
container_name: nginx
hostname: nginx-web
ports:
# 如果宿主机80端口被占用,可自行修改为其他port(>=1024)
# 0.0.0.0:要绑定的宿主机端口:docker容器内端口80
- "8081:80"
volumes:
- "/home/lory/env/nginx/www:/usr/share/nginx/html:ro"
- "/home/lory/env/nginx/conf/conf.d:/etc/nginx/conf.d:ro"
depends_on:
- php
restart: always
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
environment:
- PMA_ARBITRARY=1
env_file:
- ./walle.env
ports:
- "8285:80"
depends_on:
- db
restart: always
db:
image: "mysql:5.7"
container_name: "mysql"
env_file:
- ./walle.env
ports:
- "3307:3306"
volumes:
- "./db:/var/lib/mysql"
- "./conf/my.cnf:/etc/my.cnf"
- "./init:/docker-entrypoint-initdb.d/"
restart: always
redis:
image: "redis"
container_name: "redis"
env_file:
- ./walle.env
ports:
- "6379:6379"
restart: always
php:
image: "php:5.6-fpm"
container_name: "myphp"
env_file:
- ./walle.env
ports:
- "9000:9000"
volumes:
- "/home/lory/env/nginx/www:/www"
restart: always
php 7.2 lnmp 环境搭建
# docker version: 18.06.0+
# docker-compose version: 1.23.2+
# OpenSSL version: OpenSSL 1.1.0h
version: "3.7"
services:
web:
image: nginx
container_name: nginx
hostname: nginx-web
ports:
# 如果宿主机80端口被占用,可自行修改为其他port(>=1024)
# 0.0.0.0:要绑定的宿主机端口:docker容器内端口80
- "8081:80"
volumes:
- "/home/lory/env/nginx/www:/usr/share/nginx/html:ro"
- "/home/lory/env/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro"
- "/home/lory/env/nginx/conf/conf.d:/etc/nginx/conf.d:ro"
depends_on:
- php
restart: always
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
environment:
- PMA_ARBITRARY=1
env_file:
- ./walle.env
ports:
- "8285:80"
depends_on:
- db
restart: always
db:
image: "mysql:5.7"
container_name: "mysql"
env_file:
- ./walle.env
ports:
- "3307:3306"
volumes:
- "./db:/var/lib/mysql"
- "./conf/my.cnf:/etc/my.cnf"
- "./init:/docker-entrypoint-initdb.d/"
restart: always
redis:
image: "redis"
container_name: "redis"
env_file:
- ./walle.env
ports:
- "6379:6379"
restart: always
php:
image: "php:7.2-fpm"
container_name: "myphp"
env_file:
- ./walle.env
ports:
- "9000:9000"
volumes:
- "/home/lory/env/nginx/www:/www"
restart: always
帮助文档: https://www.jianshu.com/p/43037ce40b00
作者:henryspace 链接:https://ld246.com/article/1619165903706 来源:链滴 协议:CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0/
Read other posts