HELP! Separate Docker containers for application and Couchbase

I’m having trouble using Couchbase for my web app. This is slowly killing me and I really, really want to use this as my DataStore, I just can’t get my web app to connect to Couchbase.

My web app is one container and my Couchbase instance another, I’m not using Linux so I’m using Docker Machine on my Mac.

Mac OSX El Capitan
Docker 1.10.3
Couchbase (couchbase latest container is used)
Express (node v6, couchbase node module v2.2.5 on Ubuntu 16)

Node app.js code (sample express code)

const couchbase = require('couchbase');
(I have tried my docker machine IP the server node IP and no luck)
const cluster = new couchbase.Cluster('localhost:8091');
const bucket = cluster.openBucket('travel-sample', (error, response) => {
if (error) {
throw error;
}
console.log(response);
});

bucket.operationTimeout = 60 * 1000;

My application error: CouchbaseError: Client-Side timeout exceeded for operation. Inspect network conditions or increase the timeout.

I’m set up accessing the Couchbase UI on http://192.168.99.100:8091 and using the travel-sample data.

Bash code example

docker run -d --name my-db -p 8091-8094:8091-8094 -p 11210:11210 couchbase
I’m not using the --link arg to assign the Couchbase container to the web container (I have tried this but no luck).

I will really appreciate the help!

Thanks, Thomas.

I got it retrieving data however, I’m having to specifically point to ‘couchbase://172.17.0.2’ the individual server node. What happens if I want to create a pool and rebalance between two instances?

Here is a blog that shows how to have a simple Java application connecting to Couchbase using Docker Swarm.

Look at Docker Swarm and Service to create Couchbase Cluster for more details on creating a Couchbase cluster using Docker. It also shows how to scale the cluster as well.