Docker-Compose 搭建各种中间件

安装Docker和Docker-Compose见安装Docker&Docker-Compose

Nexus

java jar包私服仓库

  1. 编写docker-compose.yaml

vim docker-compose.yaml

version: '3'
services:
  nexus:
      restart: always
      image: sonatype/nexus3:3.17.0
      volumes:
        - /data/nexus-data:/nexus-data
      ports:
        - "8081:8081"
  1. 启动

    docker-compose up -d
    
  2. 登录控制台初始化

    localhost:8081

    设置新密码

  3. 配置仓库

    1. 新建阿里云代理仓库:Create Repository -> maven2(proxy)

      Name: aliyun-proxy

      Remote storage: https://maven.aliyun.com/repository/public

    2. 配置maven-public group

      将aliyun-proxy仓库添加的组中,位置排在maven-release后

  4. 创建任务

    创建清理快照任务

    System -> Tasks -> Create Task

    选择Maven-Delete SNAPSHOT

    配置任务名称,清理的仓库:Maven-SNAPSHOT, 清理周期:每周

Harbor

镜像仓库

  1. 获取安装包

    release: https://github.com/goharbor/harbor/releases

    wget https://download.fastgit.org/goharbor/harbor/releases/download/v2.2.2/harbor-online-installer-v2.2.2.tgz
    
  2. 解压

    tar -xf harbor-online-installer-v2.2.2.tgz

  3. 编辑配置文件

    #将原配置文件拷贝一份
    cp harbor.yaml.tmp harbor.yaml
    #编辑
    vim harbor.yaml
    
    # 配置域名
    hostname: abc.com
    # 修改端口号
    http:
      port: 8082
    harbor_admin_password: Harbor12345
    
    database:
      password: root123
      max_idle_conns: 50
      max_open_conns: 1000
    # 修改数据卷
    data_volume: /data/harbor/data
    trivy:
      ignore_unfixed: false
      skip_update: false
      insecure: false
    
    jobservice:
        max_job_workers: 10
    
    notification:
      webhook_job_max_retry: 10
    
    chart:
      absolute_url: disabled
    
    log:
      level: info
      local:
        rotate_count: 50
        rotate_size: 200M
        #修改日志路径
        location: /data/harbor/log
    _version: 2.2.0
    proxy:
      http_proxy:
      https_proxy:
      no_proxy:
      components:
        - core
        - jobservice
        - trivy
    
  4. 安装

    sudo ./install.sh	
    
  5. 登录控制台

    localhost:8082

    默认账号密码:admin Harbor12345

  6. 新建账号用于发布

  7. 配置垃圾清理定时任务,频率:每周

Elastic

  1. 编写docker-compose文件
version: '3'
services:
  es:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.13.2
    container_name: es
    environment:
      - discovery.type=single-node
      - network.publish_host=172.31.240.178
      - bootstrap.memory_lock=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./data:/usr/share/elasticsearch/data
      - ./plugins:/usr/share/elasticsearch/plugins
    ports:
      - 9200:9200
      - 9300:9300
volumes:
  data:
    driver: local
  1. 新建data与plugins目录

    mkdir data plugins
    
  2. 赋权

    chmod 777 data plugins
    
  3. 启动

    docker-compose up -d
    

Kibana

  1. 编写配置文件

    vim kibana.yml

    server.host: "0"
    elasticsearch.hosts: [ "http://172.31.240.178:9200" ]
    i18n.locale: "zh-CN"
    
  2. 编写docker-compose文件

    version: '3'
    services:
      kibana:
        image: docker.elastic.co/kibana/kibana:7.13.2
        container_name: kibana
        volumes:
          - ./kibana.yaml:/usr/share/kibana/config/kibana.yml
        ports:
          - 5601:5601
    
  3. 启动

    docker-compose up -d
    

MySQL

  1. 编写docker-compose

    version: '3.1'
    services:
        db:
            image: mysql:5.7.34
            restart: always
            environment:
                MYSQL_ROOT_PASSWORD: mysql&2021
            command:
              --default-authentication-plugin=mysql_native_password
              --character-set-server=utf8mb4
              --collation-server=utf8mb4_general_ci
              --explicit_defaults_for_timestamp=true
              --lower_case_table_names=1
            ports:
              - 3306:3306
            volumes:
              - ./data:/var/lib/mysql
    
  2. 启动

    docker-compose up -d
    

Nacos

  1. 编写环境配置

    mkdir init.d && cd init.d

    vim custom.properties

    management.endpoints.web.exposure.include=*
    
  2. 初始化数据库

    https://github.com/alibaba/nacos/blob/1.4.2/distribution/conf/nacos-mysql.sql

  3. 编写docker-compose文件

    version: "3.1"
    services:
      nacos:
        image: nacos/nacos-server:1.4.2
        container_name: nacos-standalone-mysql
        environment:
          MODE: standalone
          SPRING_DATASOURCE_PLATFORM: mysql
          MYSQL_SERVICE_HOST: 172.31.240.179
          MYSQL_SERVICE_DB_NAME: nacos
          MYSQL_SERVICE_PORT: 3306
          MYSQL_SERVICE_USER: root
          MYSQL_SERVICE_PASSWORD: mysql&2021
          MYSQL_SERVICE_DB_PARAM: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
        volumes:
          - ./standalone-logs/:/home/nacos/logs
          - ./init.d/custom.properties:/home/nacos/init.d/custom.properties
        ports:
          - "8848:8848"
        restart: on-failure
    
  4. 启动

    docker-compose up -d
    

Redis

  1. 编写docker-compose文件

    version: '3.1'
    services:
        redis:
            image: redis
            environment:
              TZ: Asia/Shanghai
            ports:
                - 6379:6379
            command: redis-server --requirepass redis@2021
            volumes:
                - ./redis-data:/var/lib/redis
    
  2. 启动

    docker-compose up -d
    

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×