Docker Swarm and Service Mode to create Couchbase Cluster explained how to create a Couchbase Cluster using Docker. It used the concept of a “master” and a “worker” service to simplify and automate the creation of cluster. The homogenous cluster was then created as shown in the architecture diagram below:
docker-service-couchbase-cluster
Complete details and background are in the Couchbase Cluster using Docker blog.

Docker 1.13 was released last week. A new feature in that release allows to deploy multi-container application defined using Docker Compose to multi-host enabled using Swarm mode. Ideally, we’d like to have a single Docker Compose definition that allows to start “master” service and start/scale “worker” service. But the “master” service, more importantly the container within the service, needs to be fully up before the “worker” service can be started. This is because the containers in the “worker” service register with the container in the “master” service to create the cluster. This typically require a bit of handcrafting as defined at Controlling Startup Order in Compose. So we’ll come back to that version later.

This blog will provide a quick refresh of the steps from the original using Docker 1.13. Read this blog for a quick how and the original blog for more details on why.

Create network:

Check the created network using docker network ls command:

Create Couchbase “master” service:

Check the created service using docker service ls command:

Create Couchbase “worker” service:

Check the created service again using docker service ls command:

Check the worker service logs using newly introduced command docker service logs couchbase-worker command. This command, newly introduced in Docker 1.13, pulls logs from all containers in the service and streams them to your console. There is no need to track down which containers are running on which hosts.

Complete logs show how the “worker” service was created and joined the cluster originally created by “master”.

Scale the cluster by scaling the Docker service:

Check the service again using docker service ls command:

Now you’ve a three node Couchbase cluster. Before rebalancing the cluster, let’s quickly check what does Couchbase Web Console shows.

Couchbase Web Console is accessible at http://localhost:8091 and shows a single Couchbase node with data, index and query service. This node was created using “master” service. Two additional nodes created using “worker” service are shown in Pending Rebalance tab:
docker-couchbase-cluster-1.13-three-nodes
Click on Rebalance to rebalance the cluster and see the fully rebalanced cluster:
docker-couchbase-cluster-1.13-rebalanced

Want to get started with Couchbase? Look at Couchbase Starter Kits.

Want to learn more about running Couchbase in containers?

Author

Posted by Arun Gupta, VP, Developer Advocacy, Couchbase

Arun Gupta is the vice president of developer advocacy at Couchbase. He has built and led developer communities for 10+ years at Sun, Oracle, and Red Hat. He has deep expertise in leading cross-functional teams to develop and execute strategy, planning and execution of content, marketing campaigns, and programs. Prior to that he led engineering teams at Sun and is a founding member of the Java EE team. Gupta has authored more than 2,000 blog posts on technology. He has extensive speaking experience in more than 40 countries on myriad topics and is a JavaOne Rock Star for three years in a row. Gupta also founded the Devoxx4Kids chapter in the US and continues to promote technology education among children. An author of several books on technology, an avid runner, a globe trotter, a Java Champion, a JUG leader, NetBeans Dream Team member, and a Docker Captain, he is easily accessible at @arungupta.

One Comment

  1. […] may also consider running Couchbase Cluster using Docker or read more about Deploying Docker Services to […]

Leave a reply