Run MongoDB with Podman
Before you start install Podman.
Set machine to rootful
Create a data directory
Setup MongoDB Authentication
First run the MongoDb container without authentication:
podman run \
--detach \
--tty \
--user $(id --user):$(id --group) \
--userns keep-id \
--name mongo-dev \
--publish 27017:27017 \
--volume ~/podman/mongo/data/db:/data/db \
mongo
Start a shell in the container:
In the container:
mongosh
# in mongo shell now
use admin
db.createUser({user:"test", pwd:"test", roles:[{role:"root", db:"admin"}]})
exit
exit
Restart MongoDB with Authentication
Stop and remove the container:
Start the container with authentication: