Connecting dockerized Couchbase server on Mac OSX with boot2docker


#1

Hi!

I have a python test where I’m seting up a docker container running Couchbase server and I cannot access that Couchbase server via Couchbase Python SDK (2.0). I’m on Mac OSX and running docker via boot2docker. I’ve read thet this configuration isn’t very good but maybe there is a way it can be done. I have a docker image based on the official Couchbase Server docker image with initialized first cluster and default bucket. Now from my host I’m running the python test where I’m trying to upsert a document into Couchbase:

bucket = Bucket('couchbase://' + HOST + '/default')
bucket.upsert('foo', 'bar')

and I’m getting following Error in a line where I do upsert:

LCB_0x2C (generated, catch: CouchbaseNetworkError, CouchbaseTransientError): <Key=u'foo', RC=0x2C[The remote host refused the connection. Is the service up?], Operational Error, Results=1, C Source=(src/multiresult.c,309)>

HOST here is my boot2docker IP, 192.168.59.103, whereas the Couchbase server host IP is something like 172.17.0.1 and the host name is random docker ID 4e4c8cae1d91.

I am able to navigete to Couchbase Server in my browser on boot2docker:8091 thanks to port forwarding, but I suppose I need to have a public IP on the docker container to be able to connecto to it with Couchbase python SDK.

I suppose I can do all I want with just using the Couchbase REST API via port forwarding, but I thought that the SDK would be a better approach.

So my questions are:

  1. Is it possible to connect to Couchbase server via python SKD in such scenario?
  2. What should be the boot2docker, docker and Couchbase settings?

#2

Hi, Did you follow the instructions provided here - https://github.com/couchbase/docker/tree/master/generate/resources/couchbase-server.
if ‘yes’ then I will let our docker experts @traun answer your question.

Thanks!

Anil Kumar


#3

Anil, thanks for your response.

I tried again (as I did earlier) few solutions from the link you provided and this time I managed to connect with the Couchbase SDK to the Couchbase Server inside the docker container. It worked with —net=host option. I was able to store documents in Couchbase with its python SDK using boot2docker hostname.


#4

Sounds great !! Hope you blog about it :wink: