普通容器编排

介绍

容器主要包括了三个数据库MongoDB,MySQL,Redis,一个消息中间件RabbitMQ。security程序依赖三个数据库,security-rabbit依赖RabbitMQ,最后forward-nginx依赖于security程序。

图解

# 容器编排
version: "3"
services:
  security:
    image: anytec/security:0.0.1
    container_name: anytec-security
    expose:
      - "9999"
    networks:
      - docker-server
    depends_on:
      - mysql
      - mongodb
      - redis
      - rabbitmq
    restart: always
    deploy:
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
  security-rabbitmq:
    image: anytec/security-rabbitmq:0.0.1
    container_name: anytec-security-rabbitmq
    expose:
      - "9998"
    networks:
      - docker-server
    depends_on:
      - rabbitmq
      - security
    restart: always
    deploy:
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
  forward-nginx:
    image: nginx:latest
    container_name: anytec-forward-nginx
    ports:
      - "10070:10070"
    networks:
      - docker-server
    depends_on:
      - security
    restart: always
    deploy:
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
    volumes:
      - /anytec/docker-server/forward-nginx/sites-enabled:/etc/nginx/sites-enabled/
      - /data/securityUI:/data/securityUI
      - /anytec/docker-server/forward-nginx/conf:/etc/nginx/
  rabbitmq:
    image: anytec/rabbitmq:3.6.15
    container_name: anytec-rabbitmq
    expose:
      - "5672"
    ports:
      - "15672:15672"
    networks:
      - docker-server
    environment:
     - RABBITMQ_DEFAULT_USER=admin
     - RABBITMQ_DEFAULT_PASS=ntech
     - RABBITMQ_USER admin
     - ENV RABBITMQ_PASSWORD ntech
     - RABBITMQ_CONFIG_FILE=/etc/rabbitmq/rabbitmq.config
     - RABBITMQ_ERLANG_COOKIE=CURIOAPPLICATION
    restart: always
    deploy:
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
  mongodb:
    image: mongo:latest
    container_name: anytec-mongodb
    expose:
      - "27017"
    networks:
      - docker-server
    restart: always
    #environment:
      #MONGO_INITDB_ROOT_PASSWORD: ntech
      #MONGO_INITDB_ROOT_USERNAME: root
    volumes:
      - /anytec/docker-server/mongodb/data:/data/db
      - /anytec/docker-server/mongodb/conf/mongodb.conf:/etc/mongodb.conf 
    deploy:
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
  redis:
    image: redis
    container_name: anytec-redis
    expose:
      - "6379"
    networks:
      - docker-server
    volumes:
      - /anytec/docker-server/redis/data:/data
      - /anytec/docker-server/redis/conf:/usr/local/etc/redis/
    command: ['redis-server', '/usr/local/etc/redis/redis.conf']
    restart: always
    deploy:
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
  mysql:
    image: anytec/mysql:5.7
    container_name: anytec-mysql
    expose:
     - "3306"
    networks:
     - docker-server
    environment:
      MYSQL_ROOT_PASSWORD: ntech
      MYSQL_ROOT_HOST: '%'
      MYSQL_DATABASE: securitydb
    volumes:
      - /anytec/docker-server/mysql/data:/var/lib/mysql
    restart: always
    deploy:
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
networks:
  docker-server:
    driver: bridge