- Docker Compose:集合管理多个Docker容器的工具,在安装docker时windows,macos默认安装Docker Compose,linux需要自己手动安装
- 去官网https://github.com/docker/compose/releases下载需要的版本
- $ sudo chmod +x ./docker-compose-linux-x86_64
- $ sudo cp ./docker-compose-linux-x86_64 /usr/bin/docker-compose
- $ docker-compose version
例子
一个用于Docker Compose的配置文件的例子,用于定义和配置两个服务:triton和copilot_proxy。
# https://github.com/fauxpilot/fauxpilot/blob/main/docker-compose.yamlversion: '3.3' # Docker Compose文件的版本services:triton: # 第一个服务,名称为tritonbuild: # 构建容器的配置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 buildbuild: # 构建容器的配置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端口