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

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,735 Points

Can't connect to mongo in container from my mongo client

I think I followed the instructions correctly, but I'm having trouble connecting to the mongo database in the container from my mongo client.

treehouse-docker: docker run -p 27017:27017 -p 28017:28017 mongotest
2017-12-10T08:51:01.369+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=0d252e070286
2017-12-10T08:51:01.370+0000 I CONTROL  [initandlisten] db version v3.6.0
2017-12-10T08:51:01.370+0000 I CONTROL  [initandlisten] git version: a57d8e71e6998a2d0afde7edc11bd23e5661c915
2017-12-10T08:51:01.370+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1t  3 May 2016
2017-12-10T08:51:01.370+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2017-12-10T08:51:01.370+0000 I CONTROL  [initandlisten] modules: none
2017-12-10T08:51:01.370+0000 I CONTROL  [initandlisten] build environment:
2017-12-10T08:51:01.370+0000 I CONTROL  [initandlisten]     distmod: debian81
2017-12-10T08:51:01.370+0000 I CONTROL  [initandlisten]     distarch: x86_64
2017-12-10T08:51:01.370+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2017-12-10T08:51:01.370+0000 I CONTROL  [initandlisten] options: {}
2017-12-10T08:51:01.373+0000 I STORAGE  [initandlisten] 
2017-12-10T08:51:01.373+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-12-10T08:51:01.373+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-12-10T08:51:01.375+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=487M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] 
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] 
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2017-12-10T08:51:01.452+0000 I CONTROL  [initandlisten] 
2017-12-10T08:51:01.471+0000 I STORAGE  [initandlisten] createCollection: admin.system.version with provided UUID: 665a8aa9-984f-49db-b968-37ad6b41e35c
2017-12-10T08:51:01.512+0000 I COMMAND  [initandlisten] setting featureCompatibilityVersion to 3.6
2017-12-10T08:51:01.521+0000 I STORAGE  [initandlisten] createCollection: local.startup_log with generated UUID: 6b0c882c-abbc-46c0-ab9c-12bcf5d6dc12
2017-12-10T08:51:01.542+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2017-12-10T08:51:01.543+0000 I NETWORK  [initandlisten] waiting for connections on port 27017
treehouse-docker: mongo
MongoDB shell version v3.4.10
connecting to: mongodb://127.0.0.1:27017
2017-12-10T00:51:32.155-0800 E QUERY    [thread1] Error: network error while attempting to run command 'isMaster' on host '127.0.0.1:27017'  :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failed
treehouse-docker: 

5 Answers

There are no such things as stupid questions. I am guessing the issue has something to do either with the ip(localhost) where the mongo service gets initialised or a conflict with an existing mongo service running (perhaps in the background).

I will let you know if i have any updates !

Robbie Thedford
Robbie Thedford
501 Points

pi@raspberrypi:~/dockerstuff $ sudo docker run -p 27017:27017 -p 28017:28017 mongotest Unable to find image 'mongotest:latest' locally docker: Error response from daemon: pull access denied for mongotest, repository does not exist or may require 'docker login': denied: requested access to the resource is denied. See 'docker run --help'.

Here is my output...I am stuck here too.

Remove "sudo"

I have the same problem ..

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,735 Points

Any ideas of what the problem might be? I suspect it might be because my mongo version in the container is newer than the version I have on my machine outside of the container. I tried asking a question about it on stackoverflow but the question got downvoted.... maybe it's a stupid question. https://stackoverflow.com/questions/47744435/error-trying-to-upgrade-mongodb-to-version-3-6-with-homebrew

Dave Faliskie
Dave Faliskie
17,793 Points

having the same problem, did anyone find a solution?

Maybe try to publish the 27017 to another port ? Like: docker run -p 26017:27017 -p 28017:28017 mongotest