Docker 学习第四课

xcguoyu 2020-06-28

搭建php-fpm apache nginx 环境

docker-compose.yml文件

networks:
  net:
    driver: bridge
    ipam:
      config:
        - 
          subnet: 192.138.0.0/16
services:
  apache:
    container_name: php-apache
    image: "httpd:2.4-alpine"
    networks:
      net:
        ipv4_address: "192.138.0.4"
    ports:
      - "8081:80"
    volumes:
      - "/root/php/:/usr/local/apache2/htdocs/"
      - "/root/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf"
  fpm:
    container_name: php-fpm
    image: "php:7.2.0-fpm-alpine3.6"
    networks:
      net:
        ipv4_address: "192.138.0.6"
    volumes:
      - "/root/php/:/php/"
  nginx:
    container_name: php-nginx
    image: "nginx:1.19.0-alpine"
    networks:
      net:
        ipv4_address: "192.138.0.5"
    ports:
      - "8082:80"
    volumes:
      - "/root/php:/usr/share/nginx/html"
      - "/root/conf/nginx.conf:/etc/nginx/nginx.conf"
version: "3.8"

2、启动容器

docker-compose up -d

相关推荐