Set up preconfigured couchbase cluster using docker-compose


#1

I have a couchbase docker image “chakrar27/couchbase” which sets up query,index,fts service and add a new data bucket. This image runs fine. Now I wanted to set up a cluster of couchbase servers (3 of them). When I try to run “docker-compose up” the REST api-s responsible for talking to couchbase API-s give me the following error -

$ docker-compose up
Pulling couchbase1 (chakrar27/couchbase:latest)…
latest: Pulling from chakrar27/couchbase
Digest: sha256:d5dc8c702075cb999263224b6bc1c65ae62970b00409e8e48056ac23a0faf4ec
Status: Downloaded newer image for chakrar27/couchbase:latest
Creating couchbasecluster_couchbase3_1
Creating couchbasecluster_couchbase1_1
Creating couchbasecluster_couchbase2_1
Attaching to couchbasecluster_couchbase1_1, couchbasecluster_couchbase2_1, couchbasecluster_couchbase3_1
couchbase1_1 | Starting Couchbase Server – Web UI available at http://:8091
couchbase2_1 | Starting Couchbase Server – Web UI available at http://:8091
couchbase3_1 | Starting Couchbase Server – Web UI available at http://:8091
couchbase1_1 | {error_logger,{{2016,9,4},{17,2,15}},“global_trace:~n~p”,[{loop_the_locker,{multi,[],[],[],‘nonode@nohost’,false,false}}]}
couchbase2_1 | {error_logger,{{2016,9,4},{17,2,15}},“global_trace:~n~p”,[{loop_the_locker,{multi,[],[],[],‘nonode@nohost’,false,false}}]}
couchbase3_1 | {error_logger,{{2016,9,4},{17,2,17}},“global_trace:~n~p”,[{loop_the_locker,{multi,[],[],[],‘nonode@nohost’,false,false}}]}
couchbase2_1 | Calling CB REST services to set up the Couchbase Server with My Settings
couchbase1_1 | Calling CB REST services to set up the Couchbase Server with My Settings
couchbase3_1 | Calling CB REST services to set up the Couchbase Server with My Settings
couchbase1_1 | * Trying 127.0.0.1…
couchbase3_1 | * Trying 127.0.0.1…
couchbase1_1 | % Total % Received % Xferd Average Speed Time Time Time Current
couchbase1_1 | Dload Upload Total Spent Left Speed
couchbase3_1 | % Total % Received % Xferd Average Speed Time Time Time Current
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0* connect to 127.0.0.1 port 8091 failed: Connection refused
couchbase3_1 | Dload Upload Total Spent Left Speed
couchbase1_1 | * Failed to connect to 127.0.0.1 port 8091: Connection refused.

My docker-compose.yml is as follows:

couchbase1:
image: chakrar27/couchbase
volumes:
- ~/couchbase/node1:/opt/couchbase/var
couchbase2:
image: chakrar27/couchbase
volumes:
- ~/couchbase/node2:/opt/couchbase/var
couchbase3:
image: chakrar27/couchbase
volumes:
- ~/couchbase/node3:/opt/couchbase/var
ports:
- 8091:8091
- 8092:8092
- 8093:8093
- 8094:8094
- 11210:11210

Am I missing something? Thx in advance.


#2

Hi Couchbase experts,

Can anyone reply to my question? Thanks.


#3

@chakrar27 You seem to be only starting three separate Couchbase servers. In order to create a cluster, your image needs to have Couchbase CLI commands that will do so.

http://blog.couchbase.com/2016/september/docker-service-swarm-mode-couchbase-cluster should help for that.


#4

Thanks. I got it. However I have the below issues -

I am running docker with docker machine on my windows 7 laptop; so I don’t have docker running natively. My docker version gives

$ docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): windows/amd64
Server version: swarm/1.2.5
Server API version: 1.22
Go version (server): go1.5.4
Git commit (server): 27968ed
OS/Arch (server): linux/amd64

How do I make docker swarm commands work wit my current set up? I tried instructions in this link https://docs.docker.com/swarm/install-w-machine/ to install swarm with docker machine. However docker swarm isn’t working. Any help will be much appreciated. Thanks.


#5

Instructions in the blog will only work for Docker 1.12 onwards only. Your client version is 1.7.1 and that’s pretty old. Can you update to the latest version?

Would recommend using Docker for Mac anyway.


#6

Thanks! I was able to set up the cluster after upgrading to docker 1.12.

I have a new issue now. How can I bring down the swarm cluster and remove the containers? I tried docker rm and docker rmi of the swarm images, but it’s assigning new imageid everytime i delete an existing one. I cannot run any other couchbase containers because the of the port conflict. I need to remove the swarm cluster and the images. Please help. Thanks.


#7

I found the command I was looking for. I stopped the service by docker service rm and it removed all the attached swarm containers.