A newer version of this documentation is available.

View Latest

Single host, multiple containers

The single host, multiple container setup is useful for testing out a multi-node cluster on your local workstation.

This setup allows you to experiment with cluster rebalancing and failover. However, it is not recommended for production use. The norm for a production cluster is that each node runs on dedicated hardware.

The networking in this setup is effectively the same as described the Software-defined network section. Docker allocates an internal IP address to each container, and each of these IPs is visible to all other containers running on the same host.

docker 03

Internal IPs should be used in the Couchbase Web Console when adding new nodes to the cluster. For external access to the Couchbase Web Console, you should expose port 8091 of exactly one of the containers when you start it.

You can choose to mount /opt/couchbase/var from the host. However, you must give each container a separate host directory:

  docker run -d -v ~/couchbase/node1:/opt/couchbase/var couchbase/server
      docker run -d -v ~/couchbase/node2:/opt/couchbase/var couchbase/server
      docker run -d -v ~/couchbase/node3:/opt/couchbase/var -p 8091:8091 couchbase/server

Set up the Couchbase Server cluster

  1. After running the last docker run command above, get the <container_id >. Let’s call that <node_3_container_id>.

  2. Get the IP address of the node 3 container by running:

    docker inspect --format '{{ .NetworkSettings.IPAddress }}' <node_3_container_id >.

    Let’s call that <node_3_ip_addr>.

  3. From the host, connect to the Couchbase Web Console via http://localhost:8091 in your browser and click on Setup.

  4. In the hostname field, enter <node_3_ip_addr >

  5. Accept all default values in the setup wizard. Choose a password that you will remember.

  6. Click the Server Nodes menu.

  7. Choose the Add Servers button in the Couchbase Web Console.

  8. For the two remaining containers:

    • Get the IP address of the container by running:

      docker inspect --format '{{ .NetworkSettings.IPAddress }}' <node_x_container_id >

      Let’s call that <node_x_ip_addr> .

    • In the Server IP Address field, use <node_x_ip_addr >.

    • In the Password field, use the password created above.