Run Docker Mongo Container

Pull the Latest Mongo Image

docker pull mongo:latest

Start the Container

docker run -d -p 27017:27017 --name=docker-mongo-db mongo:latest
  • Replace docker-mongo-dbwith the docker container name of your choice

  • Replace the ports numbers if you don't want to run it on the default ports

Stop the Container

docker stop docker-mongo-db

Replace docker-mongo-db with your container name. If you don't know what you kept while creating, simply hit docker ps

Starting the stopped container

docker start docker-mongo-db

Removing the Mongo DB Container

docker rm docker-mongo-db

Last updated