Getting Started with Server on Docker Containers
Using Docker Hub and official Couchbase Server images, it is easy to get started with Couchbase Server on Docker containers. This section walks you through the four steps to get you the simplest topology: single host, single container.
- Step 1: Ensure that Docker Engine is installed in your environment.
-
For information on how to install Docker Engine, see Docker Documentation. You can skip this step if you have Docker Engine installed already.
- Step 2: Start the Couchbase Server container
-
Use the following command to start the Couchbase Server container db:
docker run -d --name db -p 8091-8094:8091-8094 -p 11210-11211:11210-11211 couchbase
This command downloads and runs the container tagged "latest" from the Couchbase repo on Docker Hub.
If you have Couchbase Server running locally on the machine without containers, the port mappings above under the -p
option may fail. Ensure that you stop your local instance of Couchbase Server before running the above command. - Step 3: Access the Web Console
-
Access the Web Console http://localhost:8091. If the container is up and running, you’ll see the Couchbase Server Setup Screen.
- Step 4: Set up Couchbase Server
-
Walk through the Setup wizard and accept the 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
andbeer-sample
buckets to load some sample data.For detailed information on configuring the server, see Initialize the Cluster
You now have a working Couchbase Server instance in a Docker container.
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:
-
Run the interactive shell on the container:
bash -c "clear && docker exec -it db sh"
-
Navigate to the bin directory:
# cd /opt/couchbase/bin
-
Run the
cbq
command line tool:# ./cbq
-
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 running a sample application, see Couchbase Travel App.