我有一个 docker-compose 文件:
version: "2.3"
services:
backend:
image: registry.obs.liberty.edu/occ/panoptes:latest
restart: always
environment:
- SECRET_KEY=
- SQL_ENGINE=django_prometheus.db.backends.postgresql
- SQL_DATABASE=
- SQL_USER=
- SQL_PASSWORD=
- SQL_HOST=postgres_db_1
- SQL_PORT=5432
- SN_USER=
- SN_PASS=
- LDAP_USER=
- LDAP_PASS=
- ORA_USER=
- ORA_PASS=
volumes:
- static-data:/app/static:rw
networks:
- server_net
- db_net
mem_limit: 2g
server:
image: nginx:latest
restart: always
labels:
- traefik.enable=true
# insecure router (https redirect)
- traefik.http.routers.panoptes.middlewares=httpsRedirect
- traefik.http.routers.panoptes.rule=Host(`panoptes.obs.liberty.edu`) || Host(`ws://panoptes.obs.liberty.edu`)
# https router
- traefik.http.routers.panoptes-secure.rule=Host(`panoptes.obs.liberty.edu`) || Host(`wss://panoptes.obs.liberty.edu`)
docker ls 向我展示
local panoptes_static-data
但我收到此错误:
docker-compose up --build
错误:在服务“后端”中使用了名为“static-data:/app/static:rw”的卷,但在卷部分中未找到任何声明。
答案 0 :(得分:1)
只需在文件末尾添加以下内容即可使用
volumes:
static-data:
阅读下面的 docker-compose 格式
https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference