Is there an easy way to clear a mongodb database running in docker?
Or possibly delete it all and create it again?
To delete all documents in a collection, pass an empty document ({}). To limit the deletion to just one document, set to true. Omit to use the default value of false and delete all documents matching the deletion criteria.
Use the docker container prune command to remove all stopped containers, or refer to the docker system prune command to remove unused containers in addition to other Docker resources, such as (unused) images and networks.
There are a number of ways:
Regarding the last option, you shouldn't be in this scenario because your data should live on the host system and your container should be disposable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With