docker-compose常用配置

0

version: "3.1"

services:

  redis:
    container_name: redis
    image: redis:6.2.6
    restart: always
    privileged: true
    command: redis-server /etc/redis/redis.conf
    ports:
      - 6379:6379
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - $PWD/redis/data:/data
      - $PWD/redis/redis.conf:/etc/redis/redis.conf
    environment:
      - TZ=Asia/Shanghai

  es:
    container_name: es
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
    restart: always
    privileged: true
    ports:
      - 9200:9200
      - 9300:9300
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - $PWD/elasticsearch/data:/usr/share/elasticsearch/data
      - $PWD/elasticsearch/logs:/usr/share/elasticsearch/logs
      - $PWD/elasticsearch/config:/usr/share/elasticsearch/config
      - $PWD/elasticsearch/plugins:/usr/share/elasticsearch/plugins
    environment:
      - TZ=Asia/Shanghai
      - ELASTIC_PASSWORD=elastic

  nacos:
    container_name: nacos
    image: nacos/nacos-server:v2.0.3
    restart: always
    privileged: true
    ports:
      - 8848:8848
      - 9848:9848
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - $PWD/nacos:/home/nacos
    environment:
      - TZ=Asia/Shanghai
      - MODE=standalone
      # 如果没有配置该项只有登陆页面需要验证账号密码
      - NACOS_AUTH_ENABLE=true
      - PREFER_HOST_MODE=hostname

  neo4j:
    container_name: neo4j
    image: neo4j:4.4.0-community
    restart: always
    privileged: true
    ports:
      - 7474:7474
      - 7687:7687
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - $PWD/neo4j/data:/data
      - $PWD/neo4j/logs:/logs
      - $PWD/neo4j/conf:/var/lib/neo4j/conf
    environment:
      - TZ=Asia/Shanghai
      - NEO4J_AUTH=none

  mysql:
    container_name: mysql
    image: mysql:8.0.21
    restart: always
    privileged: true
    ports:
      - 3306:3306
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - $PWD/mysql/data:/var/lib/mysql
      - $PWD/mysql/conf.d:/etc/mysql/conf.d
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: 
      MYSQL_ALLOW_EMPTY_PASSWORD: root

  acgist:
    container_name: acgist
    image: openjdk:11.0.13-jre
    restart: always
    privileged: true
    command: sh /data/app/bin/startup.sh;/wait-for acgist:8080 -- echo 'success'
    links:
      - 相同compose服务
    expose:
      - 8080
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - $PWD/acgist:/data/app
      - $PWD/wait-for:/wait-for
    depends_on:
      - 依赖服务
    environment:
      - TZ=Asia/Shanghai
    external_links:
      - redis
      - neo4j
      - nacos
      - mysql

networks:
  acgist_network:
    external: true
  default:
    name: acgist_network