Cant connect to Couchbase Docker container from .NET client

Hi.
CouchbaseNetClient 2.4.7
Couchbase version 4.6.3-4136 Enterprise Edition (build-4136) (through Docker)

The container runs fine and I can accesses it from the browser but when I try to connect to it from the client I get a SocketException: {“No connection could be made because the target machine actively refused it”}.

This only happens when I try to use it as a Docker container, if Couchbase is installed locally it doesn’t have this problem.

Hi @kevin.dawson,

What command are you using to run the container? You need to make sure that the ports are exposed correctly.

For example:

docker run -d --name db -p 8091-8094:8091-8094 -p 11210:11210 couchbase:enterprise-4.6.3

Hi @matthew.groves,

I had just used docker run

docker run -d --name db1 couchbase

but was configuring the ports through Kitematic and wasn’t working. But this command has fixed it, what is the difference between this command and configuring the ports through Kitematic?

Could I go further to ask how I would create a 3 node cluster locally? do I run the same command just assigning different names and ports?

@kevin.dawson,

Check out this post: https://blog.couchbase.com/docker-and-asp-net-core-with-couchbase-server/

It’s easy to spin up a cluster inside of the docker host, but your client must also be inside of the host, otherwise it will not be able to find all the nodes.

@matthew.groves,

I’m using Docker for Windows, do I have to ‘switch to Windows Containers’? And if so I keep getting errors when I try to pull an image.

Is there a way to link the client to the Linux container as it seems to work with that when there is a single Couchbase image.

Hi @kevin.dawson,

I believe it won’t work in a Windows container (yet).

It will work with a single node, but the client must be able to reach every node directly (Couchbase isn’t a master/slave cluster). If you run an asp.net core site within the host, then it will be able to find each node. If you figure out a way to do it otherwise, I’d love to know.

@matthew.groves,

Ok i’m using the Linux containers but when I follow the tutorial in the link above and have added Docker support, when I run the app it says

Building service
Service ‘service’ failed to build: image operating system “windows” cannot be used on this platform

Any ideas on how to overcome this?

@kevin.dawson,

You get that error when deploying your ASP.NET site, I assume, not Couchbase? If so, are you using .NET Core? That tutorial is for Core only.