docker 搭建lnmp环境
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.1 lnmp 环境搭建,网上查了7.1有bug,会出现错误:
docker failed to create new listening socket: socket(): Address family not supported by protocol
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
拼搏在路上