docker-compose 设置volume绑定本地路径
2023-03-14 本文已影响0人
zbharper
搭建cvat/server 时, 需要将多个镜像公用的volume绑定在本地路径下, 可在docker-compose.yml 中编辑volume属性:
# Copyright (C) 2018-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
services:
cvat_db:
container_name: cvat_db
image: postgres:15-alpine
restart: always
environment:
POSTGRES_USER: root
POSTGRES_DB: cvat
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- cvat_db:/var/lib/postgresql/data
networks:
- cvat
cvat_redis:
container_name: cvat_redis
image: redis:4.0-alpine
restart: always
networks:
- cvat
cvat_server:
container_name: cvat_server
image: cvat/server:${CVAT_VERSION:-dev}
restart: always
depends_on:
- cvat_redis
- cvat_db
- cvat_opa
environment:
DJANGO_MODWSGI_EXTRA_ARGS: ''
ALLOWED_HOSTS: '*'
CVAT_REDIS_HOST: 'cvat_redis'
CVAT_POSTGRES_HOST: 'cvat_db'
ADAPTIVE_AUTO_ANNOTATION: 'false'
IAM_OPA_BUNDLE: '1'
no_proxy: clickhouse,grafana,vector,nuclio,opa,${no_proxy:-}
NUMPROCS: 1
DJANGO_LOG_SERVER_HOST: vector
DJANGO_LOG_SERVER_PORT: 80
CLICKHOUSE_HOST: clickhouse
CVAT_ANALYTICS: 1
CVAT_BASE_URL:
command: -c supervisord/server.conf
labels:
- traefik.enable=true
- traefik.http.services.cvat.loadbalancer.server.port=8080
- traefik.http.routers.cvat.rule=PathPrefix(`/api/`, `/git/`, `/opencv/`, `/static/`, `/admin`, `/documentation/`, `/django-rq`)
- traefik.http.routers.cvat.entrypoints=web
volumes:
- cvat_data:/home/django/data
- cvat_keys:/home/django/keys
- cvat_logs:/home/django/logs
- ./data:/home/django/tmp
networks:
cvat:
aliases:
- cvat-server
# .... 省略其他的镜像参数
volumes:
cvat_db:
cvat_data: # 设置volume cvat_data 绑定至本机 /data/cvat/data
driver_opts:
type: none
o: bind
device: /data/cvat/data
cvat_keys: # 设置volume cvat_keys 绑定至本机 /data/cvat/keys
driver_opts:
type: none
o: bind
device: /data/cvat/keys
cvat_logs: # 设置volume cvat_logs 绑定至本机 /data/cvat/logs
driver_opts:
type: none
o: bind
device: /data/cvat/logs
cvat_events_db:
networks:
cvat: