couchdb_data_volumes.rst 1.6 KB

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