docker-compose的样本

修改docker0的网卡IP

# vim /etc/docker/daemon.json 
{
"bip":"192.168.55.1/24"
}

version: '3.1'

networks:
  default:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
        - subnet: 192.168.56.0/24

services:
  mysql:
    image: mysql:5.6.40
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 123456
    # links:
    ports:
      - "3306:3306"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /home/abc/volume/mysql/data:/var/lib/mysql

  php:
    image: wordpress:php7.1-fpm
    restart: always
    ports:
      - "9000:9000"
    links:
      - mysql:mysql
    depends_on:
      - mysql
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /home/abc/volume/wwwroot:/home/wwwroot
      - /home/abc/volume/wwwlogs:/home/wwwlogs
    #  php-fpm运行的用户为www-data,需要将wwwroot的权限为[chmod a+w ]

  nginx:
    image: nginx
    restart: always
    ports:
      - "80:80"
    links:
      - mysql
      - php
    depends_on:
      - mysql
      - php
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /home/abc/volume/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro
      - /home/abc/volume/nginx/conf/fastcgi.conf:/etc/nginx/fastcgi.conf:ro
      - /home/abc/volume/nginx/conf/vhost:/etc/nginx/vhost:ro
      - /home/abc/volume/wwwroot:/home/wwwroot
      - /home/abc/volume/wwwlogs:/home/wwwlogs


  ftp:
    image: stilliard/pure-ftpd
    restart: always
    ports:
      - "21:21"
    volumes:
      - /opt/vsftp:/home/vsftp
    environment:
      FTP_USER_NAME: abc
      FTP_USER_PASS: abc0.0123
      FTP_USER_HOME: /home/vsftp

  mongo:
    image: mongo:3.2.20
    restart: always
    ports:
      - 27017:27017
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /home/abc/volume/mongo/data:/data/db
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: 123456
  
  mongo-express:
    image: mongo-express
    restart: always
    links:
      - mongo
    depends_on:
      - mongo
    ports:
      - "8081:8081"
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: 123456  
    

  #sonar:
  #  image: sonarqube
  #  restart: always
  #  ports:
  #    - "9001:9000"
  #    - "9092:9092"
  #  links:
  #    - mysql
  #  depends_on:
  #    - mysql
  #  volumes:
  #    - /home/abc/volume/sonarqube/extensions/plugins:/opt/sonarqube/extensions/plugins
  #  environment:
  #    - SONARQUBE_JDBC_USERNAME=root
  #    - SONARQUBE_JDBC_PASSWORD=123456
  #    - SONARQUBE_JDBC_URL=jdbc:mysql://mysql:3306/sonar?useUnicode=true&characterEncoding=utf8