发布于 2015-09-10 16:10:51 | 243 次阅读 | 评论: 0 | 来源: 网络整理

注解

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.

创建第一个数据库

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)

添加数据到第一个数据库

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 -Po 'd+$')/_utils/"
echo "Navigate to $URL in your browser, and use the couch interface to add data"

创建第二个数据库

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)

在第二个数据库中浏览数据

HOST=localhost
URL="http://$HOST:$(sudo docker port $COUCH2 5984 | grep -Po 'd+$')/_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.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务