docker compose down -vdocker compose down -v is right. -v is short for --volumes. It removes the containers and networks, and also deletes:
• the named volumes declared in the file, such as pgdata
• anonymous volumes attached to the containers
Plain docker compose down removes containers and networks but keeps named volumes, so your data survives. docker compose stop only stops the containers. docker compose rm -f removes stopped containers but does not delete named volumes.
Read more