sijie closed pull request #871: Issue #328 - Add docker compose example file
URL: https://github.com/apache/bookkeeper/pull/871
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docker/README.md b/docker/README.md
index 97546c687..6cd337f27 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -32,7 +32,55 @@ then run test command, such as:
 ```
 ## TL;DR -- BookKeeper cluster 
 
-If you want to setup cluster, you can play with Makefile hosted in this 
project and check its targets for a fairly complex set up example:
+If you want to setup cluster, you can play with Makefile or docker-compose 
hosted in this project and check its targets for a fairly complex set up 
example:
+
+### Docker compose
+
+```
+git clone https://github.com/apache/bookkeeper
+cd bookkeeper/docker
+docker-compose up -d
+```
+
+and it spawns and ensemble of 3 bookies with 1 dice:
+
+```
+bookie1_1    | 2017-12-08 23:18:11,315 - INFO  -
+[bookie-io-1:BookieRequestHandler@51] - Channel connected  [id: 0x405d690e,
+L:/172.19.0.3:3181 - R:/172.19.0.6:34922]
+bookie2_1    | 2017-12-08 23:18:11,326 - INFO  -
+[bookie-io-1:BookieRequestHandler@51] - Channel connected  [id: 0x7fa8645d,
+L:/172.19.0.4:3181 - R:/172.19.0.6:38862]
+dice_1       | Value = 1, epoch = 5, leading
+dice_1       | Value = 2, epoch = 5, leading
+dice_1       | Value = 4, epoch = 5, leading
+dice_1       | Value = 3, epoch = 5, leading
+```
+
+If you want to see how it behaves with more dices you only need to use
+`docker-compose up -d --scale dice=3`:
+
+```sh
+dice_3       | Value = 3, epoch = 5, following
+dice_2       | Value = 3, epoch = 5, following
+dice_1       | Value = 2, epoch = 5, leading
+dice_3       | Value = 2, epoch = 5, following
+dice_2       | Value = 2, epoch = 5, following
+dice_1       | Value = 1, epoch = 5, leading
+dice_3       | Value = 2, epoch = 5, following
+dice_2       | Value = 2, epoch = 5, following
+```
+
+You can scale the numbers of bookkeepers too selecting one of the bookies and
+using `docker-compose up -d --scale bookie1=3`
+
+Remember to shutdown the docker-compose service with `docker-compose down` to
+remove the containers and avoid errors with leftovers in next executions of the
+service.
+
+
+### Makefile
+
 ```
 git clone https://github.com/apache/bookkeeper
 cd bookkeeper/docker
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
new file mode 100644
index 000000000..41774933c
--- /dev/null
+++ b/docker/docker-compose.yml
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+version: '2'
+
+services:
+
+  zookeeper:
+    image: zookeeper
+    hostname: zookeeper
+
+  bookie1:
+    image: apache/bookkeeper
+    hostname: bookie1
+    links:
+      - zookeeper
+    environment:
+      - JAVA_HOME=/usr/lib/jvm/jre-1.8.0
+      - BK_zkServers=zookeeper:2181
+      - BK_zkLedgersRootPath = /ledgers
+
+  bookie2:
+    image: apache/bookkeeper
+    hostname: bookie2
+    links:
+      - zookeeper
+    environment:
+      - JAVA_HOME=/usr/lib/jvm/jre-1.8.0
+      - BK_zkServers=zookeeper:2181
+      - BK_zkLedgersRootPath = /ledgers
+
+  bookie3:
+    image: apache/bookkeeper
+    hostname: bookie3
+    links:
+      - zookeeper
+    environment:
+      - JAVA_HOME=/usr/lib/jvm/jre-1.8.0
+      - BK_zkServers=zookeeper:2181
+      - BK_zkLedgersRootPath = /ledgers
+
+  dice:
+    image: caiok/bookkeeper-tutorial
+    depends_on:
+      - zookeeper
+    links:
+      - zookeeper
+      - bookie3
+    environment:
+      - ZOOKEEPER_SERVERS=zookeeper:2181
+      - BOOKKEEPER_SERVER=bookie3
+


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to