docker-compose.yml 示例
yaml
version: '3.8'
services:
redis:
image: redis:7.0.12
container_name: redis-cmb
ports:
- "6371:6379" # 端口映射 # port mapping
volumes:
- redis_data:/data # 挂载redis数据目录 # mount redis data directory
networks:
- cmb-network
restart: always
mysql:
image: mysql:latest
container_name: mysql-cmb
environment:
MYSQL_ROOT_PASSWORD: root123
MYSQL_DATABASE: cmb_voiceprint_backend
MYSQL_USER: longyuan
MYSQL_PASSWORD: longyuan
ports:
- "3307:3306"
volumes:
- mysql_data:/var/lib/mysql # 挂载mysql数据目录 # mount mysql data directory
- ./init.sql:/docker-entrypoint-initdb.d/init.sql # 挂载初始化sql文件 # mount init sql file
networks:
- cmb-network
restart: always
cmb-test:
image: cmb-test:v1.0
container_name: cmb-test-cmb
ports:
- "58081:58080" # 端口映射 # port mapping
environment:
- NVIDIA_VISIBLE_DEVICES=all
volumes:
- ./cfg.py:/workplace/CMBChina-Voiceprint-Recognition-Service/cfg.py # 挂载配置文件 # mount config file
restart: always
networks:
- cmb-network
stdin_open: true
tty: true
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ["0","1"] # gpu设备id # gpu device id
capabilities:
- gpu
networks:
cmb-network:
driver: bridge
volumes:
redis_data:
driver: local
driver_opts:
type: none
device: ./data/redis # redis本机存储路径 # redis local storage path
o: bind
mysql_data:
driver: local
driver_opts:
type: none
device: ./data/mysql # mysql本机存储路径 # mysql local storage path
o: bind