couchdb_data_volumes.rst 1.6 KB

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