更新时间:2023-11-24 17:04:46
大多数标准 Docker 数据库映像都包含一个 VOLUME
行,可防止使用预填充数据创建派生映像.对于 官方 couchdb
图片 你可以看到 其 Dockerfile
中的相关行.与关系数据库映像不同,此映像不支持在首次启动时运行的脚本.
Most of the standard Docker database images include a VOLUME
line that prevents creating a derived image with prepopulated data. For the official couchdb
image you can see the relevant line in its Dockerfile
. Unlike the relational-database images, this image doesn’t have any support for scripts that run at first startup.
这意味着您需要从主机或另一个容器进行初始化.如果您可以使用它的 HTTP API 直接与它进行交互,那么这可能看起来像:
That means you need to do the initialization from the host or from another container. If you can directly interact with it using its HTTP API, then this could look like:
# Start the container
docker run -d -p 5984:5984 -v ... couchdb
# Wait for it to be up
for i in $(seq 20); do
if curl -s http://localhost:5984 >/dev/null 2>&1; then
break
fi
sleep 1
done
# Create the database
curl -XPUT http://localhost:5984/db