Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect to Mongo using the docker setup #34

Closed
mickengland opened this issue Sep 7, 2015 · 11 comments
Closed

Can't connect to Mongo using the docker setup #34

mickengland opened this issue Sep 7, 2015 · 11 comments
Labels

Comments

@mickengland
Copy link

I followed the instructions in the README.md for Docker Quick Start. After getting the three containers up and running I see this in the logs for semaphore:

Mongodb Connection Error: { [MongoError: connect EHOSTUNREACH 172.17.0.25:27017]
name: 'MongoError',
message: 'connect EHOSTUNREACH 172.17.0.25:27017' }

For the Mongo container I see this in the logs:
2015-09-07T15:21:35.814+0000 I NETWORK [initandlisten] waiting for connections on port 27017

I tried just using -p 27017:27017 for mongo, thinking maybe it was only listening on localhost but same results in logs.

@matejkramny
Copy link
Contributor

Are the containers properly linked?
The other thing is if the semaphore config uses the correct hostname as the container link defines them.

Eg if you do docker inspect <id>, it should show that the containers link and share ports

@mickengland
Copy link
Author

This is what inspect shows me for links. Only the semaphore container has links defined, as per the instructions.

$ sudo docker inspect -f "{{ .HostConfig.Links }}" semaphore
[/mongodb:/semaphore/mongo /redisio:/semaphore/redis]

sudo docker inspect -f "{{ .HostConfig.Links }}" mongodb
[]

[mick@mick-fedora semaphore]$ sudo docker inspect -f "{{ .HostConfig.Links }}" redisio
[]

For the Mongo container I see this:

"PortBindings": {
"27017/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "27017"
}

Which is making me think it is only listening on localhost but I don't know how to fix that. Do I need to add another link at run time and if so where?

@matejkramny
Copy link
Contributor

Hmm no i think docker does port forwarding.

Have you got a config file for semaphore?

@mickengland
Copy link
Author

I am using whatever configs are within the repos. I simply cloned the repo and went through the Docker Quickstart without making any changes to configs. Not sure what you are looking for but it will be identical to what is in this repository.

@mickengland
Copy link
Author

@matejkramny Thanks for looking into this. This log from semaphore shows that it is trying to connect to the IP address of the Mongo container:
$ sudo docker logs semaphore
app.js:110 Semaphore listening on port 80
Mongodb Connection Error: { [MongoError: connect EHOSTUNREACH 172.17.0.25:27017]
name: 'MongoError',
message: 'connect EHOSTUNREACH 172.17.0.25:27017' }

and a docker inspect of mongodb shows that the IP address is correct.

"Gateway": "172.17.42.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"HairpinMode": false,
"IPAddress": "172.17.0.25",

I don't know enough about nodejs/mongo to troubleshoot this even if I attach a shell to the containers.

@matejkramny
Copy link
Contributor

I'll try the tutorial and let you know.

@matejkramny
Copy link
Contributor

Hey, Sorry I was a little busy yesterday. I'll have time today after work

Thanks

@mickengland
Copy link
Author

Thanks @matejkramny I will check back later to see how it works out for you.

@matejkramny
Copy link
Contributor

I setup a brand new box (ubuntu 15.04 with docker) and copy-pasted all the steps in the "Docker quickstart" section and seems to work well.

Can you try:
docker run -it --rm --link mongodb:mongo castawaylabs/semaphore /bin/bash

Inside, you can ping mongo hostname, and prod it for open ports. If that doesn't work, then its a fault in docker or your firewall because I think docker sets up iptables to do port forwarding

@mickengland
Copy link
Author

Thanks @matejkramny I think this is a bug in docker on Fedora 22. I found some posts on this elsewhere. You can close this issue now. I will get this running on a Ubuntu system.

@Echobob
Copy link
Contributor

Echobob commented Sep 10, 2015

Closing upon request

@Echobob Echobob closed this as completed Sep 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants