Here's an explanation of what I am doing in steps:
docker run -p 27017:27017 -d mongo
mongodb://localhost:27017
After that I create a database named "Test" and a collection named "dummy" and add two dummy users manually using Mongodb compass.
After that I killed the container using
docker kill <container_id>
I then disconnect from the Mongodb compass and close it.
Then I create a new container using the same command
docker run -p 27017:27017 -d mongo
mongodb://localhost:27017
But according to the Docker concept since I am not using volumes the data is not supposed to persist.
I even tried removing all the containers manually but it still persists.
I tried connecting to mongodb://localhost:27017
without any container running and it still persists.
What am I missing here?
First of all I would verify that there are actually no volumes being used. You can do this by running docker volume ls
, or if you're using Docker Desktop, then check the Volumes tab. Docker may sometimes use anonymous volumes, so it's worth checking, see if there's any and they stand out.
Also make sure you don't have any local installations of MongoDB running on localhost:27017
. Try running ps aux | grep mongo
or similar commands, depending on your OS.
Lastly I would try deleting the stopped containers, images, networks, etc. Just to get a clean picture.