version: '3.0'
services:
  nginx:
    hostname: demo_nginx
    container_name: demo_nginx
    build:
      context: ./nginx
      dockerfile: Dockerfile
    ports:
      - "80:80"
    volumes:
      - ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/conf/conf.d:/etc/nginx/conf.d
      - ./wwwroot:/var/www/html:rw
      - ./php/sock:/sock
    depends_on:
      - php-fpm
    links:
      - php-fpm
    networks:
      - demo
  php-fpm:
    hostname: demo_php-fpm
    container_name: demo_php-fpm
    build: ./php
    ports:
      - "9000:9000"
    volumes:
      - ./php/etc:/usr/local/etc
      - ./wwwroot:/var/www/html:rw
      - ./php/sock:/sock
    links:
      - mysql
    networks:
      - demo
  mysql:
    hostname: demo_mysql
    container_name: demo_mysql
    build: ./mysql
    ports:
      - "3306:3306"
    volumes:
      #- ./mysql/conf:/etc/mysql/conf
      - ./data:/var/lib/mysql
    command: "--character-set-server=utf8"
    environment:
      #设置免密登录
      MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
      #MYSQL_DATABASE: db1
      #MYSQL_USER: user1
      #MYSQL_PASSWORD: pwd1
    networks:
      - demo
networks:
  demo: