Docker Postgress Clear all Data

You can try:

docker volume rm $(docker volume ls -q)

Otherwise, the proper way to do it would be to do:

docker rm -f -v postgres_container_name

However, I don't think the volumes are the issue. When you do a docker run --rm -it postgres the entrypoint loads some configuration and restarts the database, so it is expected to see that message.


For docker-compose the correct way to remove volumes would be docker-compose down --volumes or docker-compose down --rmi all --volumes.

For more information see https://docs.docker.com/compose/reference/down/.


It ended up being that docker compose was mounting folders on startup, these folders are specified in docker-compose.yml like so:

volumes:
  - ./code:/etc/puppetlabs/code/
  - ./puppet/ssl:/etc/puppetlabs/puppet/ssl/
  - ./puppet/serverdata:/opt/puppetlabs/server/data/puppetserver/

The folders are updated on use. By removing them I was able to fix my problem.