docker-composer 的安装
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
构建脚本:
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
docker 文档: https://www.runoob.com/docker/docker-compose.html
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于