应用

使用docker部署常用组件

2020-10-03  本文已影响0人  陈洪华

[TOC]

以下无特殊说明的,皆是docker-compose的剧本,且使用的都是公网仓库中指定版本的景象,无需额外寻找镜像制作方式。

MYSQL

version: '2'
services:
  mysql:
    image: mysql:5.7
    container_name: mysql
    ports:
    - 3306:3306
    restart: always
    environment:
    - "TZ=Asia/Shanghai"
    - "character-set-server=utf8mb4"
    - "default-character-set=utf8mb4"
    - "MYSQL_ROOT_PASSWORD=chenhonghua"
    - "lower_case_table_names=1"
    - "default_storage_engine=InnoDB"
    - "skip-name-resolve"
    - "sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/mysql/data:/var/lib/mysql:rw"
    # 挂载自定义配置文件(可选)
    # - "/var/lib/docker/data/mysql/conf/my.cnf:/etc/mysql/conf.d/my.cnf:ro"
    # 挂载语句目录(可选)
    # - "/var/lib/docker/data/mysql/sql:/home/sql:ro"

REDIS

version: '2'
services:
  redis:
    image: redis:5.0.5
    container_name: redis
    ports:
    - 6379:6379
    restart: always
    environment:
    - "TZ=Asia/Shanghai"
    # - requirepass=自定义连接密码(可选)
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/redis/data:/var/lib/redis:rw"
    # 挂载自定义配置文件(可选)
    # - "/var/lib/docker/data/redis/conf/6379.conf:/usr/local/etc/redis/redis.conf:ro"

MONGO

version: '2'
services:
  mongo:
    image: mongo:4.2
    container_name: mongo
    restart: always
    ports:
    - 27017:27017
    environment:
    - "MONGO_INITDB_ROOT_USERNAME=root"
    - "MONGO_INITDB_ROOT_PASSWORD=自定义root密码"
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/mongo/data:/data/db"
  # 以下为可选,mongo-express是中mongo可视化应用
  mongo-express:
    image: mongo-express:0.54
    container_name: mongo-express
    restart: always
    ports:
    - 58081:8081
    environment:
    - "ME_CONFIG_MONGODB_ADMINUSERNAME=root"
    - "ME_CONFIG_MONGODB_ADMINPASSWORD=自定义mongo-express密码"

POSTGRES

version: '2'
services:
  postgres:
    image: 'postgres:10.14'
    container_name: postgres
    restart: always
    environment:
    - "TZ=Asia/Shanghai"
    - "GITLAB_TIMEZONE=Beijing"
    # - "DEBUG=true"
    - "DB_EXTENSION=pg_trgm"
    - "POSTGRES_PASSWORD=数据库root密码"
    # 以下为初始化一个用户和库
    - "DB_USER=gitlab"
    - "DB_PASS=gitlab"
    - "DB_NAME=gitlab_production"
    ports:
    - 5432:5432
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/postgres/data:/var/lib/postgresql/data"

GITLAB

version: '2'
services:
  gitlab:
    image: 'gitlab/gitlab-ce:13.1.4-ce.0'
    container_name: gitlab-ce
    restart: always
    hostname: 'gitlab.example.com'
    ports:
    # 80端口或者443还是留给gitlab比较好,否则挺奇怪的
    - 80:80
    - 10443:443
    - 10022:22
    volumes:
    # 挂载配置文件,主要还是gitlab.rb文件,虽然无论是否配置都能跑,但最好还是配置以下,不然用起来各种奇怪
    # 另外,如果没有进行配置,官方的这个镜像正常运行需要5~6GB内存
    # 通过配置,将这个镜像集成的模组、组件都关闭,能让运行内存降低到800MB左右
    - "/var/lib/docker/data/gitlab/config:/etc/gitlab"
    # 挂载数据目录
    - "/var/lib/docker/data/gitlab/data:/var/opt/gitlab"
    # 挂载日志目录
    - "/var/lib/docker/data/gitlab/logs:/var/log/gitlab"
    # 挂载备份目录
    - "/var/lib/docker/data/gitlab/backups:/var/opt/gitlab/backups"

SVN

version: '2'
services:
  mysql:
    image: garethflowers/svn-server:1.3.2
    container_name: svn
    # network_mode: host
    restart: always
    ports:
    - 3690:3690
    environment:
    - "TZ=Asia/Shanghai"
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/svn/data:/var/opt/svn"

ZOOKEEPER

version: '2'
volumes:
  data-zookeeper:
services:
  zookeeper:
    image: zookeeper:3.4.13
    container_name: zookeeper
    restart: always
    ports:
    - 2181:2181
    environment:
    - "TZ=Asia/Shanghai"
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/zookeeper:/opt/zookeeper-3.4.13/data:rw"

KAFKA

version: '2'
services:
  kafka:
    image: kafkamanager/kafka-manager
    container_name: kafka
    restart: always
    ports:
    - 9092:9092
    environment:
    - "TZ=Asia/Shanghai"
    # 下面的zookeeper-server-host和kafka-server-host可以是hosts文件内的别名,这样剧本就不用经常改了,如果是K8S就更方便了,改为svc名
    # - "ZK_HOSTS=zookeeper-server-host"
    # - "ZK_PORT=22181"
    # - KAFKA_MANAGER_AUTH_ENABLED=false
    - "KAFKA_ZOOKEEPER_CONNECT=zookeeper-server-host:2181"
    - "KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka-server-host:9092"
    - "KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092"
    volumes:
    # 挂载宿主的hosts文件,将常用IP别名化,避免剧本经常变动,如果是K8S的容器,则可省略
    - /etc/hosts:/etc/hosts:ro

ELASTICSEARCH

version: '2'
services:
  elasticsearch:
    image: elasticsearch:6.7.0
    container_name: elasticsearch
    ports:
    - 9200:9200
    - 9300:9300
    environment:
    - "cluster.name=es-cluster"
    - "node.name=es01"
    - "node.attr.rack=r1"
    - "node.master=true"
    - "node.data=true"
    - "bootstrap.memory_lock=false"
    - "action.destructive_requires_name=true"
    - "http.cors.enabled=true"
    - "http.cors.allow-origin=*" 
    - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/elasticsearch/data:/usr/share/elasticsearch/data:rw"
    # 挂载插件目录
    - "/var/lib/docker/data/elasticsearch/plugins:/usr/share/elasticsearch/plugins:ro"

KIBANA

version: '2'
services:
  kibana:
    image: kibana:6.6.0
    container_name: kibana
    # network_mode: host
    # 需要的再开,又不常用
    # restart: always
    ports:
    - 5601:5601
    environment:
    - "TZ=Asia/Shanghai"
    - "ELASTICSEARCH_URL=http://<ES服务器的IP>:<ES服务器的端口,一般为9200>"
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/kibana/data:/usr/share/kibana/data:rw"
    # 挂载插件目录
    - "/var/lib/docker/data/kibana/data:/usr/share/kibana/node_modules"
#    - "/var/lib/docker/data/kibana/kibana-optimize-.babelcache.json:/usr/share/kibana/optimize/.babelcache.json"

NEXUS

version: '2'
services:
  nexus:
    image: nexus:/nexus-data
    container_name: nexus
    network_mode: host
    environment:
    - "TZ=Asia/Shanghai"
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/nexus/data:/nexus-data:rw"

LDAP

version: '2'
services:
  ldap:
    image: osixia/openldap:1.3.0
    container_name: ldap
    restart: always
    ports:
    - 389:389
    - 636:636
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/ldap/data:/usr/local/ldap"

JENKINS

version: '2'
services:
  jenkins:
    image: jenkins/jenkins:2.235.5-lts-centos7
    container_name: jenkins
    # network_mode: host
    restart: always
    ports:
    - 8080:8080
    - 50000:50000 
    environment:
    - "TZ=Asia/Shanghai"
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/jenkins/data:/var/jenkins_home:rw"

ZENDAO

version: '2'
services:
  zentao:
    image: easysoft/zentao:12.3.3
    container_name: zentao
#    network_mode: zentao
    ports:
    - 10080:80
    restart: always
    environment:
    - "TZ=Asia/Shanghai"
    - "MYSQL_ROOT_PASSWORD=管理员密码"
    volumes:
    # 挂载数据目录
    - "/var/lib/docker/data/zentao/data_zentaopms:/www/zentaopms"
    # 挂载元数据目录
    - "/var/lib/docker/data/zentao/data_mysql:/var/lib/mysql"
上一篇下一篇

猜你喜欢

热点阅读