Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start a mongodb shell in docker container?

Tags:

docker

mongodb

To start the container, I am typing the following command:

sudo docker run -i -t -p 28000:27017 mongo:latest /usr/bin/mongod --smallfiles 

But I want to open the shell in this container to type the mongo commands. What command should I run to do the same?

like image 911
Madhavi Jouhari Avatar asked Oct 05 '15 09:10

Madhavi Jouhari


1 Answers

You can run the interactive mongo shell by running the following command:

docker run -it -p 28000:27017 --name mongoContainer mongo:latest mongo 

Otherwise, if your container is already running, you can use the exec command:

docker exec -it mongoContainer mongo 
like image 111
vladzam Avatar answered Oct 11 '22 11:10

vladzam