Couchbase Server 4.0 was recently released and can be downloaded and easily installed. Getting Started with Couchbase explains in very simple and easy steps on how to get started with Couchbase. But when living in a container world, everything is a Docker image. And Couchbase also has a Docker image.
This blog will explain how you can easily start a Couchbase Server 4.0 as a Docker image.
Install and Configure Docker
On Mac or Windows, this is achieved by install Docker Machine. Docker Machine to Setup Docker Host explain in detail on how to install and configure Docker Machine.
Here is a brief summary to get you started with Docker:
- Download Docker client:
1234567> curl -L https://get.docker.com/builds/Darwin/x86_64/docker-1.8.3 > /usr/local/bin/docker% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 8664k 100 8664k 0 0 4139k 0 0:00:02 0:00:02 --:--:-- 4139k> chmod +x /usr/local/bin/docker
- Download Docker Machine script:
12345678> curl -L https://github.com/docker/machine/releases/download/v0.4.1/docker-machine_darwin-amd64 > /usr/local/bin/docker-machine% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 586 0 586 0 0 1103 0 --:--:-- --:--:-- --:--:-- 1103100 11.8M 100 11.8M 0 0 2733k 0 0:00:04 0:00:04 --:--:-- 3458k> chmod +x /usr/local/bin/docker-machine
- Create Docker Machine host:
12345678> docker-machine create --driver=virtualbox defaultCreating VirtualBox VM...Creating SSH key...Starting VirtualBox VM...Starting VM...To see how to connect Docker to this machine, run: docker-machine env default
- Setup Docker client to connect to this host:
123> eval $(docker-machine env default)
Now your current shell is configured where the Docker client can run containers on the Docker Machine.
Run Couchbase Docker Container
- Starting a Docker container on this machine is pretty straight forward. The CLI downloads the image from Docker Hub and then runs it on the Machine:
123456789101112131415161718192021222324> docker run -d -p 8091:8091 couchbaseUnable to find image 'couchbase:latest' locallylatest: Pulling from library/couchbaseba2b457ecfb2: Pull complete26180b0fe8fb: Pull completeedd7c1974a70: Pull complete57bca5139a13: Pull complete5eb89c4f7e1a: Pull complete46b6bac823d2: Pull complete6845430f4274: Pull complete92d9ea0b826c: Pull completec02a4d9a78c4: Pull complete904ac92614ac: Pull completee924e7d4b1dc: Pull completebbe8a967cf05: Pull complete35fb2c30481e: Pull complete68eb883fd0c7: Pull completefe1b3bdb1e2f: Pull completelibrary/couchbase:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.Digest: sha256:388b710593a7a643c49bf38c4b16eb8e175dccac093e9aa8dea5bd2e2d326efdStatus: Downloaded newer image for couchbase:latest5b789d2319486ce8a4a4d6a866d8212dde1464601451b9a84a8d3bf80e8aa935
runcommand runs the container using the image id specified as the last argument,
8091from the container to
8091on the Docker Machine,
-druns the container in background and prints the container id.
- Watch the container status as:
12345> docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES5b789d231948 couchbase "/entrypoint.sh couch" 7 minutes ago Up 7 minutes 8092/tcp, 11207/tcp, 11210-11211/tcp, 0.0.0.0:8091->8091/tcp, 18091-18092/tcp sick_yonath
- Find out IP address of the Docker Machine:
1234> docker-machine ip default192.168.99.100
- Access the setup console at 192.168.99.100:8091, make sure to specify the exact IP address in your case. This will show the screen:
Configure Couchbase Server
First run of Couchbase Server requires you to configure it, lets do that next!
- Click on the Setup button. Scroll to bottom of the screen, change the Data RAM Quota to 500 (MB-16530), and click on Next.
- In Couchbase, data is stored in buckets. The server comes pre-installed with some sample buckets. Select the
travel-samplebucket to install it and click on
- Configure the bucket by taking defaults:
- Enter personal details, agree to T&C, click on
- Provide administrator credentials:
Nextto complete the installation. This brings up Couchbase Web Console:
It takes a few seconds for the
travel-sample bucket to be fully loaded. And once that is done, your Couchbase server is ready to roll!
You can also watch the following presentation from Couchbase Connect: