Deploying a Single Node Cluster with Docker

Deploying a Single Node Cluster with Docker

To run a single node cluster, you need to deploy a single Couchbase Server container representing the single node.

For deployments with Couchbase Server containers, use the Couchbase Docker images available on Docker Hub.

Note: Before you begin, review the container requirements section for prerequisites and resource requirements for the containers.
  1. Start the Couchbase Server container, db, using the following command:
    docker run -d --name db -p 8091-8094:8091-8094 -p 11210:11210 couchbase

    This command downloads and runs the container tagged "latest" from the Couchbase repo on Docker Hub.

    Check the Docker logs to verify that the container has started:
    docker logs db
    If the container is started, it should return the following output:
    Starting Couchbase Server -- Web UI available at http://<ip>:8091
    Note: If Couchbase Server is running locally on the machine without containers, the port mappings specified using the -p option may fail. Ensure that you stop your local instance of Couchbase Server before running the above command.
  2. From the browser, access the Web Console using http://localhost:8091. If the container is up and running, you should see the Couchbase Server Setup Screen.

  3. Set up Couchbase Server. Walk through the Setup wizard and accept default values.

    You may need to lower the RAM allocated to various services to fit within the bounds of the resource for the containers. Enable the `travel-sample` and `beer-sample` buckets to load some sample data.

This is all that is needed for a single node deployment of Couchbase Server. If you want to add nodes to your cluster, see Deploying a Multi-node Cluster with Docker.

Running a N1QL Query

Open the Web Console at http://localhost:8091 and switch to the Query tab. Run the following N1QL query:
SELECT name FROM `beer-sample` WHERE  brewery_id ="mishawaka_brewing";
To run a query from command line query tool:
  1. Run the interactive shell on the container:
    bash -c "clear && docker exec -it db sh"
  2. Navigate to the bin directory:
    # cd /opt/couchbase/bin
  3. Run the cbq command line tool:
    # ./cbq
  4. Execute a N1QL query on the `beer-sample` bucket:
    cbq> SELECT name FROM `beer-sample` WHERE  brewery_id ="mishawaka_brewing";

For more query samples, see Running Your First N1QL Query.

Connect via SDK

Simply run your application through the Couchbase Server SDKs on the host and point it to http://localhost:8091/pools to connect to the container.

For information on deploying a sample application to a container, see Couchbase Travel App.