Sunday, August 2, 2020

Setup MongoDB on Docker

Description:  Here I have explained, how to setup MongoDB on docker container and create one more container for MongoDB client and link that container with MongoDB container.

Setup MongoDB on Docker:
  • First I pull MongoDB image from docker hub using below command
  • Run mongo container and run it in background using below command 
  • You can verify by using docker ps command 
  • Now we setup another instance which act as client and link with mongodb container to connect mongodb. The name of the container will different in my case it is nifty_driscoll you can get it in docker ps -a command output. The container run in interactive mode with bash.


  • To connect mongodb you need ip address of mongodb server, you can find it using docker inspect DockerID command
  • Once you login in client docker machine you can use mongo using below command
  • You have successfully deployed MongoDB server and client

No comments:

Post a Comment