I was trying to create a small POC using the docker image couchbase:community-7.0.2
. When I create a docker container (and bind/forward all the ports) and connect like so:
var options = new ClusterOptions {
EnableTls = false,
ConnectionString = "couchbase://localhost",
UserName = "Administrator",
Password = "password"
};
var cluster = await CB.Cluster.ConnectAsync( options );
var waitOptions = new WaitUntilReadyOptions().CancellationToken( cancellationToken );
await cluster.WaitUntilReadyAsync( TimeSpan.FromSeconds( 5 ), waitOptions ).ConfigureAwait( false );
await cluster.Buckets.CreateBucketAsync(
new BucketSettings { Name = "test", BucketType = BucketType.Couchbase, RamQuotaMB = 100 } );
var buckets = await cluster.Buckets.GetAllBucketsAsync();
Everything seems to work.
But when I create a console application that runs in another container that shares a docker network bridge. I get one of two issues.
1- If my connection string is: couchbase://db
(db being the docker network name/alias for the Couchbase container) I’m able to connect to the cluster, but then I get the following error when calling “GetAllBucketsAsync”
Couchbase.ServiceNotAvailableException: Service mgmt is either not configured or cannot be reached. Check logs for details.
Couchbase.Core.ClusterContext.GetRandomNodeForService(ServiceType service, String bucketName)
Couchbase.Core.ServiceUriProvider.GetRandomManagementUri()
Couchbase.Management.Buckets.BucketManager.GetUri(String bucketName)
Couchbase.Management.Buckets.BucketManager.GetAllBucketsAsync(GetAllBucketsOptions options)
The container seems to be fine since I can connect from the host machine using: http://localhost:8091/
2 - If I try and connect using the management port couchbase://db:8091
it seems to fail while waiting for the cluster to be ready after getting “Orphaned responses observed”
var waitOptions = new WaitUntilReadyOptions().CancellationToken( operationCancelToken );
_logger?.LogInformation( "Waiting for cluster ready." );
await cluster.WaitUntilReadyAsync( notifyInterval, waitOptions ).ConfigureAwait( false );
_logger?.LogInformation( "Cluster is ready." ); // Never gets here
Is there any reason why Couchbase might have issues connecting over a docker network, but would be fine connecting from a host machine to a container?