| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,53 @@ |
| 0 |
+:title: Sharing data between 2 couchdb databases |
|
| 1 |
+:description: Sharing data between 2 couchdb databases |
|
| 2 |
+:keywords: docker, example, package installation, networking, couchdb, data volumes |
|
| 3 |
+ |
|
| 4 |
+.. _running_redis_service: |
|
| 5 |
+ |
|
| 6 |
+Create a redis service |
|
| 7 |
+====================== |
|
| 8 |
+ |
|
| 9 |
+.. include:: example_header.inc |
|
| 10 |
+ |
|
| 11 |
+Here's an example of using data volumes to share the same data between 2 couchdb containers. |
|
| 12 |
+This could be used for hot upgrades, testing different versions of couchdb on the same data, etc. |
|
| 13 |
+ |
|
| 14 |
+Create first database |
|
| 15 |
+--------------------- |
|
| 16 |
+ |
|
| 17 |
+Note that we're marking /var/lib/couchdb as a data volume. |
|
| 18 |
+ |
|
| 19 |
+.. code-block:: bash |
|
| 20 |
+ |
|
| 21 |
+ COUCH1=$(docker run -d -v /var/lib/couchdb shykes/couchdb:2013-05-03) |
|
| 22 |
+ |
|
| 23 |
+Add data to the first database |
|
| 24 |
+------------------------------ |
|
| 25 |
+ |
|
| 26 |
+We're assuming your docker host is reachable at `localhost`. If not, replace `localhost` with the public IP of your docker host. |
|
| 27 |
+ |
|
| 28 |
+.. code-block:: bash |
|
| 29 |
+ |
|
| 30 |
+ HOST=localhost |
|
| 31 |
+ URL="http://$HOST:$(docker port $COUCH1 5984)/_utils/" |
|
| 32 |
+ echo "Navigate to $URL in your browser, and use the couch interface to add data" |
|
| 33 |
+ |
|
| 34 |
+Create second database |
|
| 35 |
+---------------------- |
|
| 36 |
+ |
|
| 37 |
+This time, we're requesting shared access to $COUCH1's volumes. |
|
| 38 |
+ |
|
| 39 |
+.. code-block:: bash |
|
| 40 |
+ |
|
| 41 |
+ COUCH2=$(docker run -d -volumes-from $COUCH1) shykes/couchdb:2013-05-03) |
|
| 42 |
+ |
|
| 43 |
+Browse data on the second database |
|
| 44 |
+---------------------------------- |
|
| 45 |
+ |
|
| 46 |
+.. code-block:: bash |
|
| 47 |
+ |
|
| 48 |
+ HOST=localhost |
|
| 49 |
+ URL="http://$HOST:$(docker port $COUCH2 5984)/_utils/" |
|
| 50 |
+ echo "Navigate to $URL in your browser. You should see the same data as in the first database!" |
|
| 51 |
+ |
|
| 52 |
+Congratulations, you are running 2 Couchdb containers, completely isolated from each other *except* for their data. |