Looking for steps for configuring couchbase docker containers so that it is accessible from other hosts in the network.
Created a three node couchbase docker container cluster.
Commands used to start the containers:-
docker run -d --name mydb1 -p 192.168.0.1:8091-8094:8091-8094 -p 192.168.0.1:11210:11210 couchbase:community
docker run -d --name mydb2 -p 192.168.0.2:8091-8094:8091-8094 -p 192.168.0.2:11210:11210 couchbase:community
docker run -d --name mydb3 -p 192.168.0.3:8091-8094:8091-8094 -p 192.168.0.3:11210:11210 couchbase:community
netstat output :-
netstat -an|grep 8091
tcp 0 0 192.168.0.1:8091 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.2:8091 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.3:8091 0.0.0.0:* LISTEN
docker inspect command output :-
docker inspect --format ‘{{ .NetworkSettings.IPAddress }}’ mydb1
172.17.0.2
docker inspect --format ‘{{ .NetworkSettings.IPAddress }}’ mydb2
172.17.0.3
docker inspect --format ‘{{ .NetworkSettings.IPAddress }}’ mydb3
172.17.0.4
The above are the docker assigned IPs of each node.
I am able to access couchbase console from each of the following url from outside of the container host.
http://192.168.0.1:8091
http://192.168.0.2:8091
http://192.168.0.3:8091
But when I write a java program using couchbase java SDK to connect to the remote cluster I get the following message mentioning the IP 172.17.0.3 which is an internal docker IP. After sometime I get timeout exception.
May 02, 2017 1:55:39 PM com.couchbase.client.core.node.CouchbaseNode
WARNING: DNS Reverse Lookup of 172.17.0.3 is slow, took 4500ms
The code snippet I have used to connect to remote couchbase cluster is
public static final String bucketName = "my-test-bucket";
public static final String bucketPassword = "";
public static final List<String> nodes = Arrays.asList("192.168.0.1","192.168.0.2","192.168.0.3")
…
CouchbaseEnvironment couchEnv = DefaultCouchbaseEnvironment.builder()
.connectTimeout(100000)
.viewTimeout(30000)
.queryTimeout(30000)
.autoreleaseAfter(50000)
.build();
cluster = CouchbaseCluster.create(Env,nodes);
bucket = cluster.openBucket(bucketName, bucketPassword);
Please note that the external machines do not have access to docker internal IPs.
Need help in getting the docker configuration right so that the external java clients can access the couchbase cluster.