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

Docker Jetty App link to mongodb #14

Open
sli4 opened this issue Jan 21, 2016 · 2 comments
Open

Docker Jetty App link to mongodb #14

sli4 opened this issue Jan 21, 2016 · 2 comments

Comments

@sli4
Copy link

sli4 commented Jan 21, 2016

Docker Container Jetty publish web app met the exception, thanks for help!

com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongo-java-driver-3.0.3.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ~[mongo-java-driver-3.0.3.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:127) ~[mongo-java-driver-3.0.3.jar:na]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_65]
Caused by: java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_65]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_65]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_65]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_65]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_65]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_65]
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50) ~[mongo-java-driver-3.0.3.jar:na]
at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongo-java-driver-3.0.3.jar:na]
... 3 common frames omitted

@tjheslin1
Copy link

tjheslin1 commented Aug 10, 2016

Try conecting to the container running mongo:

$ docker exec -it mongo_container bash

then run:

$ root@238723a36aaa:/data# cat /etc/hosts

Look at the hostnames as a result of this command. I am running mongoDb in docker and got the following line: (where '238723a36aaa' is the containers ID)

172.17.0.2 238723a36aaa

I then tried:
new MongoClient(new ServerAddress("172.17.0.2", 27017), mongoClientBuilder.build());

and was able to connect!

Here are my docker run commands:

docker run --name mongo_banking -d -p 27017:27017 -v /tmp/mongo:/data/db mongo-banking
docker run -d -p 8085:8085 --link mongo_banking:events_store --name aggregate aggregate-image

Note: that the "aggregate" container is running an embedded Jetty server. Similar to what you have configured I believe.

Best,
Tom

Edit:

I came across your issue googling for the exact same error. This issue is not specific to this repo and I haven't used this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants