How to start a mongodb shell in docker container?

后端 未结 3 1508
故里飘歌
故里飘歌 2020-12-22 19:12

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

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

B

3条回答
  •  Happy的楠姐
    2020-12-22 19:50

    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
    

提交回复
热议问题