自己开发用的docker-compose文件,一键开发环境(etcd,mysql,redis,nginx,mongo,nsqdb,nginx,phpmyadmin,kafka)

6 篇文章 0 订阅
3 篇文章 0 订阅

先装docker、

再装python-pip

再装 docker-compose

保存以下代码为 docker-compose.yml

再当前目录执行  docker-compose up  起来了看下日志、没问题就掐掉、重新执行 docker-compose up -d 后台运行

断口映射已做好、直觉当做本机(127.0.0.1)用即可

 

version: '3'

networks:
  dev:


services:
#######################  mongodb  ######################
  mongo:
   container_name: mongo
   image: mongo
   restart: always
   environment:
     MONGO_INITDB_ROOT_USERNAME: root
     MONGO_INITDB_ROOT_PASSWORD: 123456
   networks:
     - dev
   ports:
     - 27017:27017
   
#####################  kafka  ######################        
  zookeeper:
     image: wurstmeister/zookeeper
     ports:
       - "2181:2181"
     networks:
      - dev
  kafka:
     image: wurstmeister/kafka
     depends_on: [ zookeeper ]
     ports:
       - "9092:9092"
     environment:
       KAFKA_ADVERTISED_HOST_NAME: 192.168.33.20
       KAFKA_CREATE_TOPICS: "test:1:1"
       KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
     volumes:
       - ./data/kafka/docker.sock:/var/run/docker.sock
     networks:
      - dev
      
#######################  etcd  ########################
  etcd:
    container_name: etcd
    image: bitnami/etcd:3
    #image: quay.io/coreos/etcd:v3.3
    restart: always
    environment:
      - ALLOW_NONE_AUTHENTICATION=yes
      - ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
    networks:
      - dev
    ports:
      - 2379:2379
      - 2380:2380
      
#######################  nsqdb ########################     
  nsqlookupd:
    image: nsqio/nsq
    command: /nsqlookupd
    networks:
      - dev
    hostname: nsqlookupd
    ports:
      - "4161:4161"
      - "4160:4160"
  nsqd:
    image: nsqio/nsq
    command: /nsqd --lookupd-tcp-address=nsqlookupd:4160 -broadcast-address=192.168.33.20
    depends_on:
      - nsqlookupd
    hostname: nsqd
    networks:
      - dev
    ports:
      - "4151:4151"
      - "4150:4150"
  nsqadmin:
    image: nsqio/nsq
    command: /nsqadmin --lookupd-http-address=nsqlookupd:4161
    depends_on:
      - nsqlookupd
    hostname: nsqadmin
    ports:
      - "4171:4171"
    networks:
      - dev

#######################  mysql5.7  ########################
  mysql5.7:
    container_name: mysql5.7
    image: mysql:5.7
    restart: always
    command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    environment:
      - MYSQL_ROOT_PASSWORD=123456
    networks:
      - dev
    volumes:
     - ./data/mysql:/var/lib/mysql  ##自建目录
    ports:
      - 3306:3306
      
  phpmyadmin:
    image: phpmyadmin
    container_name: phpmyadmin
    environment:
      - PMA_ARBITRARY=1
    restart: always
    links: 
      - mysql5.7
    ports:
      - 8090:80
    volumes:
      - /sessions
    networks:
      - dev
      
########################  redis  ########################
  redis:
    image: bitnami/redis:latest
    container_name: redis
    restart: always
    ports:
      - 6379:6379
    networks:
      - dev
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - ./redis.conf:/usr/local/etc/redis/redis.conf:rw
      - ./data/redis:/data:rw     ##自建目录
    command:
      /bin/bash -c "redis-server /usr/local/etc/redis/redis.conf"
      
########################  nginx  ########################
  web:
    container_name: web
    image: nginx:latest
    restart: always
    volumes:
      - "./etc/nginx:/etc/nginx"    ##自建目录
      - "./logs:/logs"              ##自建目录
    ports:
      - 80:80
      - 443:443
    networks:
      - dev

#################################Microservices##############################
   
  service_user:
   container_name: service_user
   image: alpine:latest
   restart: always
   volumes:
     - "./bin/service_user:/service_user"
     - "./etc/service_user.yaml:/service_user.yaml"
     - "./logs:/logs"
   command: /service_user -f /service_user.json
   networks:
     - dev
   ports:
     - 8080:8080

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值