Optimus Prime
Optimus Prime

Reputation: 63

Docker AspNet Core + Couchbase

I have a .net core api which includes the required couchbase-sdk installed The api has docker support through visual studio. I added couchbase section in the docker-compose file to use couchbase, when I run the docker-compose up command both the api and couchbase is running. I am able to view the couchbase UI.

Question: what will my connectionstring be in the appsettings.json file to connect to this couchbase cluster because its running inside docker which will have its ip addresses. I cannot simply go localhost:8091?

In the compose file, how do I set the username and password, default bucket to use in couchbase, I had a look at the docs on docker/couchbase and couldnt find anything, couldnt find much docs on google about this also.

enter image description here

Upvotes: 2

Views: 411

Answers (2)

Matthew Groves
Matthew Groves

Reputation: 26141

All the documentation about Couchbase on Docker can be found here: https://docs.couchbase.com/server/6.0/install/getting-started-docker.html and there's also some quick-start information here: https://hub.docker.com/_/couchbase

When you say the "connection string" for Couchbase, this is normally the IP address or network address of one or more Couchbase nodes. Since you are using docker-compose, I think "db" might be what you use instead.

As for your other questions: "how do I set the username and password, default bucket to use in couchbase" -> there is no way that I know of currently to do this with docker or docker compose using the off-the-shelf docker images supplied by Couchbase. If you want to automate this, you could create your own docker image (based on the Couchbase image) that runs a script (details too long for this SO answer, but you could check out this blog post, for instance).

Alternatively, there is a Kubernetes operator that is capable of doing exactly this (for Couchbase Enterprise only), which I guess isn't too helpful if you're set on using docker-compose.

Upvotes: 1

Chris Pratt
Chris Pratt

Reputation: 239290

You should use the hostname, not IP, and that hostname will be the service name in the docker-compose.yml file. In other words, use db.

Upvotes: 2

Related Questions