Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Introduction to Docker Why Docker? Building an Image and Running a Container

Josman Perez
Josman Perez
10,117 Points

Access shell of mongotest

How to access shell of mongo after running mongotest container

Josman Perez
Josman Perez
10,117 Points

I want to answer my own question just in case you might be facing the same doubt

2 Answers

Josman Perez
Josman Perez
10,117 Points

If you want to access the shell of a container after running the:

docker run -p 27017:27017 -p 28017:28017 mongotest

You have to expose the shell in the container, if you are running docker >= 1.3

You need you to type in your host OS:

docker exec -it [IDofContainerOrName] bash`

And the you'll be prompted with the mongo db shell of the container :)

This is awesome, Thanks bro

Nikhilesh Katakam
Nikhilesh Katakam
1,175 Points

If you want to get the container id to use in the above command posted by Josman Perez use: docker container ls

Or even simpler: docker ps