第一步:启动Docker Desktop
第二步:docker 镜像下载CouchDB
docker pull couchdb
[注意]从官网上注意到当前CouchDB最新版本为3.3.2。根据参考文献提示,想直接从Docker Hub上拉取CouchDB(默认为最新版本)。
通过界面提示来看,下载正常。但是,接下来安装出现问题。
第三步:运行CouchDB
低版本的CouchDB运行使用如下命令:
docker run -d -p 5984:5984 couchdb
其中, -d 以后台模式运行 -p 本地端口:couchdb 容器内容端口。
但是,对于当前3.X版本,出现如下错误提示:
*************************************************************
ERROR: CouchDB 3.0+ will no longer run in "Admin Party"
mode. You *MUST* specify an admin user and
password, either via your own .ini file mapped
into the container at /opt/couchdb/etc/local.ini
or inside /opt/couchdb/etc/local.d, or with
"-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password"
to set it via "docker run".
*************************************************************
*************************************************************
ERROR: CouchDB 3.0+ will no longer run in "Admin Party"
mode. You *MUST* specify an admin user and
password, either via your own .ini file mapped
into the container at /opt/couchdb/etc/local.ini
or inside /opt/couchdb/etc/local.d, or with
"-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password"
to set it via "docker run".
*************************************************************
上述提示是从Docker Desktop的LOG记录中观察到的。使用上述命令在命令行下安装时,没有出现任何有关提示。
分析官网上的有关介绍,如下:
Changed in version 3.0.0: CouchDB requires an admin account to start. If an admin account has not been created, CouchDB will print an error message and terminate.
CouchDB server administrators and passwords are not stored in the _users
database, but in the last [admins]
section that CouchDB finds when loading its ini files. See :config:intro for details on config file order and behaviour. This file (which could be something like /opt/couchdb/etc/local.ini
or /opt/couchdb/etc/local.d/10-admins.ini
when CouchDB is installed from packages) should be appropriately secured and readable only by system administrators:
[admins]
;admin = mysecretpassword
admin = -hashed-6d3c30241ba0aaa4e16c6ea99224f915687ed8cd,7f4a3e05e0cbc6f48a0035e3508eef90
architect = -pbkdf2-43ecbd256a70a3a2f7de40d2374b6c3002918834,921a12f74df0c1052b3e562a23cd227f,10000
Administrators can be added directly to the [admins]
section, and when CouchDB is restarted, the passwords will be salted and encrypted. You may also use the HTTP interface to create administrator accounts; this way, you don’t need to restart CouchDB, and there’s no need to temporarily store or transmit passwords in plaintext.
根据文献[4]的提示,更改为在命令行上运行如下命令后,成功:
docker run -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=admin123 -d couchdb
注:这里是现场指定管理员名称与密码,更典型的操作应该是通过上面提示中的配置.INI文件中设定。
检验是否运行成功
运行命令docker ps,显示如下:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f51d4628d610 couchdb "tini -- /docker-ent…" 8 seconds ago Up 6 seconds 4369/tcp, 5984/tcp, 9100/tcp keen_black
通过Docker Desktop观察到的结果如下图所示:
参考文献
- https://blog.51cto.com/u_14625168/2468944
- https://couchdb.apache.org/
- https://docs.couchdb.org/en/stable/config/auth.html#config-admins
- https://forums.docker.com/t/admin-password-requested/117663/3