Docker-部署docker-compose以及管理服务

部署docker-compose以及管理服务


文章目录

  • 部署docker-compose以及管理服务
    • @[TOC]
  • 前言
  • 一、docker-compose是什么?
    • 1、介绍
    • 2、 功能
  • 二、安装docker-compose
    • 1.yum直接安装
    • 2.二进制安装
    • 3.pip安装
  • 三、docker-compose部署服务
    • 1.编写docker-compose.yml文件
  • 总结

前言

Docker 是一个开源的容器化平台,可以帮助我们快速构建、打包和运行应用程序。而 Docker Compose 则是用于管理多个容器应用的工具,可以轻松定义和管理多个容器之间的关系。

一、docker-compose是什么?

1、介绍

Docker Compose是一个用来定义和运行复杂应用的Docker工具。Compose 通过一个配置文件来管理多个Docker容器,在配置文件中,所有的容器通过services来定义,然后使用docker-compose脚本来启动,停止和重启应用,和应用中的服务以及所有依赖服务的容器,非常适合组合使用多个容器进行开发的场景

2、 功能

Docker Compose功能点:

  • 提供工具用于定义和运行多个docker容器应用;
  • 使用yaml文件来配置应用服务(docker-compse.yml);
  • 可以通过一个简单的命令docker-compse up可以按照依赖关系启动所有服务;
  • 可以通过一个简单的命令docker-compose down停止所有服务;
  • 当一个服务需要的时候,可以很简单地通过–scale进行扩容;

二、安装docker-compose

compose安装方式有三种,以下来介绍。

1.yum直接安装

#安装docker-compose,如果没有python3会安装python3yum install -y docker-compose

2.二进制安装

从github上下载docker-compose二进制文件安装

3.pip安装

pip install docker-compose

三、docker-compose部署服务

1.编写docker-compose.yml文件

version: '3.5'
services:
 etcd:
    container_name: milvus-etcd
    image: quay.io/coreos/etcd:v3.5.5-arm64
    restart: always
    environment:
      - ETCD_AUTO_COMPACTION_MODE=revision
      - ETCD_AUTO_COMPACTION_RETENTION=1000
      - ETCD_QUOTA_BACKEND_BYTES=4294967296
      - ETCD_SNAPSHOT_COUNT=50000
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/data/volumes/etcd:/etcd
    command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd

  minio:
    container_name: milvus-minio
    image: minio/minio:latest
    restart: always
    environment:
      MINIO_ACCESS_KEY: minioadmin
      MINIO_SECRET_KEY: minioadmin
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/data/volumes/minio:/minio_data
    command: minio server /minio_data
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3
      
  standalone:
    container_name: milvus-standalone
    image: milvusdb/milvus:latest
    restart: always
    command: ["milvus", "run", "standalone"]
    environment:
      ETCD_ENDPOINTS: etcd:2379
      MINIO_ADDRESS: minio:9000
      swappiness: 0
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/conf/milvus/milvus.yaml:/milvus/configs/milvus.yaml
      - ${DOCKER_VOLUME_DIRECTORY:-.}/data/volumes/milvus:/var/lib/milvus
    ports:
      - "19530:19530"
      - "9091:9091"
    depends_on:
      - "etcd"
      - "minio"
      
  doc_mongodb:
    image: artifacts.iflytek.com/docker-private/aimind/mongo:4.2.6
    container_name: doc_mongodb
    volumes:
      - "/data/docqa/data/mongo/configdb/:/data/configdb/"
      - "/data/docqa/data/mongo/data/db/:/data/db/"
    restart: always
    environment:
      - MONGO_INITDB_ROOT_USERNAME=aimind
      - MONGO_INITDB_ROOT_PASSWORD=mongoforaimind2021
    ports:
      - "27017:27017"
  doc-minio:
    container_name: doc-minio
    image: minio/minio:latest
    restart: always
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/data/minio/data:/data
      - ${DOCKER_VOLUME_DIRECTORY:-.}/data/minio/config:/root/.minio
    command: server /data --console-address ":9090"
    ports:
      - "9001:9000"
      - "9090:9090"
  doc_es:
    image: artifacts.iflytek.com/docker-private/aimind/elasticsearch:8.4.1
    container_name: doc_es
    volumes:
      - "/data/docqa/data/esdata/:/usr/share/elasticsearch/data"
      - "/data/docqa/conf/elasticsearch/plugins/:/usr/share/elasticsearch/plugins/"
    ports:
      - "19300:9300"
      - "19200:9200"
    restart: always
    environment:
      - "discovery.type=single-node"
      - "ES_JAVA_OPTS=-Xms256m -Xmx16g"
      - xpack.security.enabled=false
      - bootstrap.memory_lock=true
      - cluster.routing.allocation.disk.threshold_enabled=false
    ulimits:
      memlock:
        soft: -1
        hard: -1
  doc_backend:
    depends_on:
      - etcd
      - minio
      - standalone
      - doc_mongodb
      - doc_es
    image: artifacts.docqa:test.556
    container_name: doc_backend
    environment:
      - "SPRING_PROFILES_ACTIVE=dev"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/usr/bin/docker:/bin/docker"
      - "/data/docqa/data/docqa/:/mnt/parastor/aimind"
      - "/data/docqa/conf/backend/application-dev.yml:/home/doc/application-dev.yml"
    ports:
      - "8906:8906"
    restart: always
  doc_frontend:
    depends_on:
      - doc_backend
    image: artifacts.frontend-test:0.0.1-aimind--light-test.51
    container_name: doc_frontend
    volumes:
      - "/data/docqa/conf/frontend/nginx.conf:/etc/nginx/nginx.conf"
    ports:
      - "30880:80"
    restart: always
  doc_sim:
    image: artifacts.sim:1.0.0
    container_name: doc_sim
    ports:
      - "8901:8901"
    restart: always    
    
networks:
  default:
    name: doc

总结

以上是docker-compose在实际项目中的使用配置,大家可以参考。

你可能感兴趣的:(docker,docker,容器)