Start Couchbase Using Docker Compose

Couchbase Forums has a question Can’t use N1QL on docker-compose. This blog will show how to run Couchbase using Docker Compose and run a N1QL query.

Docker ComposeN1QL

What is Docker Compose?

Docker Compose allows you to define your multi-container application with all of its dependencies in a single file, then spin your application up in a single command.

Docker Compose introduced v3 in Docker 1.13. How do you know what version of Docker are you running?

docker version command gives you that information:

Couchbase Docker Compose File

Now if you see this version of Docker, then you can use the following Compose file:

In this Compose file:

  • v3 version of Compose file. If you are using an older version of Docker, then you can consider using v2 version of Compose file.
  • arungupta/couchbase Docker image is used to start Couchbase server.  This image is created as explained at github.com/arun-gupta/docker-images/tree/master/couchbase. It uses Couchbase REST API to pre-configure the Couchbase server.
  • Ports 8091, 8092, 8093, 8094, 11210 are exposed.
  • Only a single replica of Couchbase server is started.

Couchbase can be started in a couple of ways using this Compose file.

Couchbase using Docker Compose on Single Docker Host

If you want to start Couchbase on a single host (such as provisioned by Docker for Mac or a single Docker Machine), then use the command:

This will show the warning message but starts Couchbase server:

Check the status of started service using the command docker-compose ps:

All the exposed ports are shown and Couchbase is accessible at http://localhost:8091. Use the credentials Administrator/password to access the web console.

Now you can create buckets and connect from CBQ and run N1QL queries. For example:

Typically, you may be able to scale the services started by Docker Compose using docker-compose scale command. But this will not be possible in our case as the ports are exposed. Scaling a service will cause port conflict.

The container can be brought down using the command docker-compose down.

Couchbase using Docker Compose on Multi-host Swarm-mode Cluster

Docker allows multiple hosts to be configured in a cluster using Swarm-mode. This can be configured using the command docker swarm init.

Once the cluster is initialized, then the Compose file can be used to start the cluster:

It shows the output:

This creates a Docker service and the status can be seen using the command docker service ls:

Check the tasks/containers running inside the service using the command docker service ps couchbase_db:

Here again, you can connect to the Couchbase server and run N1QL queries:

The service, and thus the container running in the service, can be terminated using the command docker service couchbase_db.

Any more questions? Catch us on Couchbase Forums.

You may also consider running Couchbase Cluster using Docker or read more about Deploying Docker Services to Swarm.

Want to learn more about running Couchbase in containers?

  • Couchbase on Containers
  • Couchbase Developer Portal
  • @couchhasedev and @couchbase

Source: blog.couchbase.com/couchbase-using-docker-compose/

Be Sociable, Share!
  • Tweet

3 thoughts on “Start Couchbase Using Docker Compose

  1. If you are waiting for methods to remember passwords in microsoft edge so you may have all useful information from here and will also show you exact ways to clarify all your hurdles. Have a visit for once.

  2. Introducing the application and usage of the application is very detailed and easy to understand. with lots of great features.

  3. Nice Post. Notwithstanding for those understudies who are in detail making the most of their classes, it very well may exasperate do as such much homework on the double. That is the reason it’s savvy to procure homework custom paper administration online to assist you with your homework. It assuages you from the pressure and exertion and gives you a chance to appreciate the comfortable hours. Recorded beneath are a few components to remember before future such administrations.

Leave a Reply

Your email address will not be published. Required fields are marked *