Brandon Kauffman
Brandon Kauffman

Reputation: 1865

Named Volume Error when runninf docker-compose up

I have a docker-compose file:

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 shows me

local               panoptes_static-data

But I get this error:

docker-compose up --build

ERROR: Named volume "static-data:/app/static:rw" is used in service "backend" but no declaration was found in the volumes section.

Upvotes: 0

Views: 908

Answers (1)

Tarun Lalwani
Tarun Lalwani

Reputation: 146490

Just add below at the end of the file and it should work

volumes:
  static-data:

Read the below for the docker-compose format

https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference

Upvotes: 1

Related Questions