先装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