How to setup mongodb on docker The next command will download the latest mongodb docker image and will create a container with the given port, name and volumes to persist db data. docker run -d -p 9000:27017 --name example-mongo -v mongo-data:/data/db mongo:latest