Docker Compose: 集合管理Docker的工具安装

  • Docker Compose:集合管理多个Docker容器的工具,在安装docker时windows,macos默认安装Docker Compose,linux需要自己手动安装
  1. 去官网https://github.com/docker/compose/releases下载需要的版本
  2. $ sudo chmod +x ./docker-compose-linux-x86_64
  3. $ sudo cp ./docker-compose-linux-x86_64 /usr/bin/docker-compose
  4. $ docker-compose version

例子

        一个用于Docker Compose的配置文件的例子,用于定义和配置两个服务:triton和copilot_proxy。

# https://github.com/fauxpilot/fauxpilot/blob/main/docker-compose.yaml

version: '3.3' # Docker Compose文件的版本

services:
  triton: # 第一个服务,名称为triton
    build: # 构建容器的配置
      context: . # 构建上下文位置为当前目录
      dockerfile: triton.Dockerfile # 使用triton.Dockerfile来构建容器
    # 容器启动后运行的命令
    command: bash -c "CUDA_VISIBLE_DEVICES=${GPUS} mpirun -n 1 --allow-run-as-root /opt/tritonserver/bin/tritonserver --model-repository=/model" 
    shm_size: '2gb' # 分配给容器的共享内存大小
    volumes: # 挂载点配置
      - ${
    
    MODEL_DIR}:/model # 将宿主机的MODEL_DIR目录挂载到容器的/model目录下
      - ${
    
    HF_CACHE_DIR}:/root/.cache/huggingface # 将宿主机的HF_CACHE_DIR目录挂载到容器的/root/.cache/huggingface目录下
    ports: # 端口映射配置
      - "8000:8000" # 将宿主机的8000端口映射到容器的8000端口
      - "${TRITON_PORT}:8001" # 将宿主机的TRITON_PORT端口映射到容器的8001端口
      - "8002:8002" # 将宿主机的8002端口映射到容器的8002端口
    deploy: # 部署配置
      resources: # 资源预留配置
        reservations: # 预留资源配置
          devices: # 设备配置
            - driver: nvidia # 使用NVIDIA GPU驱动程序
              count: all # 使用所有可用的GPU设备
              capabilities: [gpu] # 使用GPU功能

  copilot_proxy: # 第二个服务,名称为copilot_proxy
    # For dockerhub version
    # image: moyix/copilot_proxy:latest

    # For local build
    build: # 构建容器的配置
      context: . # 构建上下文位置为当前目录
      dockerfile: proxy.Dockerfile # 使用proxy.Dockerfile来构建容器
    command: uvicorn app:app --host 0.0.0.0 --port 5000 # 容器启动后运行的命令
    env_file: # 环境变量配置
      # Automatically created via ./setup.sh
      - .env # 读取.env文件中的环境变量
    ports: # 端口映射配置
      - "${API_EXTERNAL_PORT}:5000" # 将宿主机的API_EXTERNAL_PORT端口映射到容器的5000端口

猜你喜欢

转载自blog.csdn.net/ResumeProject/article/details/132125272
今日推荐