2

I have created docker container for Couchbase. The service is up and running but with the following command,

couchbase-cli cluster-init -c $CB_SERVER_IPADDR:8091 --cluster-init-username=admin --cluster-init-password=couchbase --cluster-init-ramsize=2048

I get a server node in couchbase with the name as its internal IP address - 172.x.x.x. Then when i create bucket using the following command,

couchbase-cli bucket-create -c $CB_SERVER_IPADDR:8091 -u admin -p couchbase --bucket=heartbeat --bucket-type=couchbase --bucket-ramsize=500 --bucket-replica=0 --wait

buckets gets created. But when my web application which is in a different container, communicates with couchbase with the IP address of the docker host where the Couchbase server is running, i get the following error message

2014-08-05 21:49:00.106 INFO com.couchbase.client.CouchbaseConnection:  Reconnecting due to exception on {QA sa=172.x.x.x/172.x.x.x:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
java.net.NoRouteToHostException: No route to host
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
        at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:485)
        at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:322)
        at com.couchbase.client.CouchbaseConnection.run(CouchbaseConnection.java:288)

I could see that my application is using the server node name which is the internal IP address to communicate with the couchbase and thus the error. Any help appreciated

cucucool
  • 3,777
  • 8
  • 48
  • 63
  • Take a look at http://stackoverflow.com/a/24997739/92516 - the solution should be the same – DaveR Aug 06 '14 at 06:33

1 Answers1

0

Your web application docker container is not able to resolve the host name of the couchbase docker container.

You would need to link the web application container and couchbase container together.

Below will create a name "couchbase" for your couchbase instance, this name will later be referenced by web application docker container

sudo docker run -d --name couchbase <your couchbase image name>

Below will add an entry "$your_couchbase_docker_container_IP couchbase" into /etc/hosts on your web application docker container

sudo docker run -d -P --link couchbase:couchbase <your web application image name>

Then in your web application, you can use couchbase:8091 to access the couchbase docker container

More detail on "docker link" is available at https://docs.docker.com/userguide/dockerlinks/

Ronggang
  • 119
  • 1
  • 4
  • What if the couchbase and the web application containers run on two different VMs ? The problem is with the couchbase server node set to the container IP address. Any suggestions ? – cucucool Oct 28 '15 at 01:26