首页 > 解决方案 > 无法创建 marklogic rest api 实例

问题描述

我正在尝试使用以下配置创建 rest-api 实例:rest-api.json

{
 "rest-api": {
     "name": "restdb-api",
     "database": "restdb",
     "port": "8003",
     "xdbc-enabled": true,
     "forests-per-host": 1,
     "error-format": "json"
  }
}

curl --anyauth --user admin:admin -i -X POST -d @"./REST/rest-api.json"  -H "Content-type: application/json" http://localhost:8002/LATEST/rest-apis

端点返回 201 created,但我无法在http://localhost:8003访问创建的端点。我曾尝试使用其他端口,但同样的事情正在发生。端口 8003 未在侦听。请帮我解决这个问题。

HTTP/1.1 401 Unauthorized
Server: MarkLogic
WWW-Authenticate: Digest realm="public", qop="auth", nonce="36473d01f5e45a:ND9/6NHD0sw9o2y/xad/uQ==", opaque="e9594a1b7e019a97"
Content-Type: text/html; charset=utf-8
Content-Length: 209
Connection: Keep-Alive
Keep-Alive: timeout=5

HTTP/1.1 201 Created
Server: MarkLogic
Content-Length: 0
Connection: Keep-Alive
Keep-Alive: timeout=5

标签: restmarklogicmarklogic-9

解决方案


由于您说您在本地 docker 容器上运行,因此您可能需要发布端口。

请参阅 Docker公开

请从链接中注意 - “EXPOSE 指令实际上并没有发布端口。它充当构建图像的人和运行容器的人之间的一种文档类型,关于打算发布哪些端口。在运行容器时实际发布端口,使用 docker run 上的 -p 标志发布和映射一个或多个端口,或者 -P 标志发布所有暴露的端口并将它们映射到高位端口。”

希望有帮助!


推荐阅读