mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
![James Turnbull](/assets/img/avatar_default.png)
* Added User Guide section outlines. * Added User Guide to menu. * Moved HTTPS example to articles. * Replaced Hello World example with User Guide. * Moved use cases out of examples. * Updated Introduction to add User Guide. * Redirected migrated /use and /articles links. * Added Docker.io section * Added Dockerized section * Added Using Docker section * Added Docker Images section * Added Docker Links section * Added Docker Volumes section Docker-DCO-1.1-Signed-off-by: James Turnbull <james@lovedthanlost.net> (github: jamtur01)
43 lines
1.6 KiB
Markdown
43 lines
1.6 KiB
Markdown
page_title: Dockerizing a CouchDB Service
|
|
page_description: Sharing data between 2 couchdb databases
|
|
page_keywords: docker, example, package installation, networking, couchdb, data volumes
|
|
|
|
# Dockerizing a CouchDB Service
|
|
|
|
> **Note**:
|
|
> - **If you don't like sudo** then see [*Giving non-root
|
|
> access*](/installation/binaries/#dockergroup)
|
|
|
|
Here's an example of using data volumes to share the same data between
|
|
two CouchDB containers. This could be used for hot upgrades, testing
|
|
different versions of CouchDB on the same data, etc.
|
|
|
|
## Create first database
|
|
|
|
Note that we're marking `/var/lib/couchdb` as a data volume.
|
|
|
|
$ COUCH1=$(sudo docker run -d -p 5984 -v /var/lib/couchdb shykes/couchdb:2013-05-03)
|
|
|
|
## Add data to the first database
|
|
|
|
We're assuming your Docker host is reachable at `localhost`. If not,
|
|
replace `localhost` with the public IP of your Docker host.
|
|
|
|
$ HOST=localhost
|
|
$ URL="http://$HOST:$(sudo docker port $COUCH1 5984 | grep -o '[1-9][0-9]*$')/_utils/"
|
|
$ echo "Navigate to $URL in your browser, and use the couch interface to add data"
|
|
|
|
## Create second database
|
|
|
|
This time, we're requesting shared access to `$COUCH1`'s volumes.
|
|
|
|
$ COUCH2=$(sudo docker run -d -p 5984 --volumes-from $COUCH1 shykes/couchdb:2013-05-03)
|
|
|
|
## Browse data on the second database
|
|
|
|
$ HOST=localhost
|
|
$ URL="http://$HOST:$(sudo docker port $COUCH2 5984 | grep -o '[1-9][0-9]*$')/_utils/"
|
|
$ echo "Navigate to $URL in your browser. You should see the same data as in the first database"'!'
|
|
|
|
Congratulations, you are now running two Couchdb containers, completely
|
|
isolated from each other *except* for their data.
|