Remove a named volume with docker-compose?

Bosh picture Bosh · Aug 4, 2017 · Viewed 33.1k times · Source

If I have a docker-compose file like:

version: "3"
services:
  postgres:
    image: postgres:9.4
    volumes:
      - db-data:/var/lib/db
volumes:
  db-data:

... then doing docker-compose up creates a named volume for db-data. Is there a way to remove this volume via docker-compose? If it were an anonymous volume, then docker-compose rm -v postgres would do the trick. But as it stands, I don't know how to remove the db-data volume without reverting to docker commands. It feels like this should be possible from within the docker-compose CLI. Am I missing something?

Answer

herm picture herm · Aug 4, 2017
docker-compose down -v

removes all volumes attached. See the docs