MySQL
version: '3.1' services: mysql: # 服务的名称 restart: always # 代表只要docker启动,那么这个容器就跟着一起启动 image: daocloud.io/library/mysql:5.7.4 # 指定镜像路径 container_name: mysql # 指定容器名称 ports: - 3306:3306 # 指定端口号的映射 environment: MYSQL_ROOT_PASSWORD: root # 指定MySQL的ROOT用户登录密码 TZ: Aisa/Shanghai # 指定时区 volumes: - /opt/docker_mysql/data:/var/lib/mysql # 映射数据卷
RabbitMQ
version: "3.1" services: rabbitmq: image: daocloud.io/library/rabbitmq:management restart: unless-stopped container_name: rabbitmq ports: - 5672:5672 - 15672:15672 volumes: - ./data:/var/lib/rabbitmq
kafka
version: '3.5' services: zookeeper: image: wurstmeister/zookeeper # 镜像 container_name: zookeeper ports: - "2181:2181" # 对外暴露的端口号 kafka: image: wurstmeister/kafka # 镜像 container_name: kafka volumes: - /opt/docker_kafka/data:/var/lib/kafka # 挂载位置 ports: - "9092:9092" environment: KAFKA_ADVERTISED_HOST_NAME: 42.192.6.39 # 宿主机IP -- client 要访问的broker地址 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 # kafka运行是基于 zookeeper 的,通过端口连接zookeeper KAFKA_BROKER_ID: 0 # 每个容器就是一个 broker,设置器对应的ID KAFKA_ADVERTISED_PORT: 9092 KAFKA_LOG_RETENTION_HOURS: 120 KAFKA_MESSAGE_MAX_BYTES: 10000000 KAFKA_REPLICA_FETCH_MAX_BYTES: 10000000 KAFKA_GROUP_MAX_SESSION_TIMEOUT_MS: 60000 KAFKA_NUM_PARTITIONS: 3 KAFKA_DELETE_RETENTION_MS: 1000 KAFKA_LOG_DIRS: "/kafka/logs" # 设置 kafka 日志位置 KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true' # kafka 自动创建 topic,对于生产者与消费者连接的 TOPIC 不存在自动创建 KAFKA_DELETE_TOPIC_ENABLE: 'true' # kafka 开启删除 topic,开了自动创建,删除的也要开,否则删除后还会自动创建 kafka-manager: image: sheepkiller/kafka-manager # 镜像:开源的web管理kafka集群的界面 container_name: kafka-manager environment: ZK_HOSTS: 42.192.34.125 # 修改:宿主机IP ports: - "9009:9000" # 暴露端口 9000这个端口冲突太多
mongoDB
version: '3.1' services: mongodb: image: daocloud.io/library/mongo:2.7.6 container_name: mongodb volumes: - ./data/mongod.conf:/etc/mongod.conf - ./data/db:/data/db - ./data/logs:/data/logs ports: - 27017:27017 restart: always command: mongod --auth environment: - MONGO_INITDB_ROOT_USERNAME=root - MONGO_INITDB_ROOT_PASSWORD=root
Nginx
version: '3.1' services: nginx: restart: always image: daocloud.io/library/nginx:1.12.0-alpine container_name: nginx ports: - 80:80 volumes: - /opt/docker_nginx/conf.d/:/etc/nginx/conf.d
Redis
version: '3.1' services: redis: image: daocloud.io/library/redis:5.0.7 restart: always container_name: redis command: - /bin/bash - -c - redis-server /usr/local/bin/redis.conf/redis.conf --requirepass "root" environment: - TZ=Asia/Shanghai ports: - 6379:6379 volumes: - ./data:/var/lib/redis - ./redis.conf:/usr/local/bin/redis.conf
标签:常用,compose,name,redis,KAFKA,docker,kafka,data,ports From: https://www.cnblogs.com/wq-9/p/16716143.html