我已经成功地在linux主机上安装了mongodb (redhat 8)。蒙哥什工作得很好,他在27017端口上听讲。我想安装mongod作为码头容器,并将其连接到运行在主机上的mongod(外部码头!)。我已经尝试过以下修理机-Compose.yml:
version: '3.7'
services:
mongo-express:
image: mongo-express
restart: always
# ports:
# - 8081:8081
environment:
ME_CONFIG_MONGODB_SERVER: localhost
ME_CONFIG_MONGODB_ADMINUSERNAME: ${MONGO_USER}
ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_PASS}
ME_CONFIG_BASICAUTH_USERNAME: ${MONGO_USER}
ME_CONFIG_BASICAUTH_PASSWORD: ${MONGO_PASS}
network_mode: host我将端口设置注释为与network_mode:host.不兼容。
结果:将构建容器并发出以下警告:
mongoexpress-mongo-express-1 | Welcome to mongo-express
mongoexpress-mongo-express-1 | ------------------------
mongoexpress-mongo-express-1 |
mongoexpress-mongo-express-1 |
mongoexpress-mongo-express-1 | (node:7) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
mongoexpress-mongo-express-1 | (node:7) UnhandledPromiseRejectionWarning: MongoError: not authorized on config to execute command { listCollections: 1, filter: {}, cursor: {}, nameOnly: false, lsid: { id: UUID("2e2c2b92-4d5d-47d0-9c37-59e52dd3a5df") }, $db: "config" }
mongoexpress-mongo-express-1 | at Connection.<anonymous> (/node_modules/mongodb/lib/core/connection/pool.js:453:61)
mongoexpress-mongo-express-1 | at Connection.emit (events.js:314:20)
mongoexpress-mongo-express-1 | at processMessage (/node_modules/mongodb/lib/core/connection/connection.js:456:10)
mongoexpress-mongo-express-1 | at Socket.<anonymous> (/node_modules/mongodb/lib/core/connection/connection.js:625:15)
mongoexpress-mongo-express-1 | at Socket.emit (events.js:314:20)
mongoexpress-mongo-express-1 | at addChunk (_stream_readable.js:297:12)
mongoexpress-mongo-express-1 | at readableAddChunk (_stream_readable.js:272:9)
mongoexpress-mongo-express-1 | at Socket.Readable.push (_stream_readable.js:213:10)
mongoexpress-mongo-express-1 | at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
mongoexpress-mongo-express-1 | (node:7) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
mongoexpress-mongo-express-1 | (node:7) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.试图访问主机上的mongo速递会给:
[root@d20p280a mongoexpress]# curl localhost:8081
curl: (7) Failed to connect to localhost port 8081: Connection refused码头ps:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5cc00d871e82 mongo-express "tini -- /docker-ent…" 13 minutes ago Up 13 minutes mongoexpress-mongo-express-1任何提示都很感谢-谢谢!
发布于 2022-11-16 08:07:21
像往常一样,细节是魔鬼的所在。缺少的线索是错误日志中的这个条目:
mongoexpress-mongo-express-1 | (node:7) UnhandledPromiseRejectionWarning: MongoError: not authorized on config to execute command { listCollections: 1, filter: {}, cursor: {}, nameOnly: false, lsid: { id: UUID("2e2c2b92-4d5d-47d0-9c37-59e52dd3a5df") }, $db: "config" }The是正确的,如图所示。mongodb中的管理用户只有以下角色:"userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase",它缺少listCollections特权。奇怪的是,芒果快车甚至没有启动服务器。我希望网页浏览器中会出现错误信息。感谢所有花时间研究这个问题的人。这是现在使用的管理角色:
roles: [
{
role: 'root',
db: 'admin'
}
]https://stackoverflow.com/questions/74449342
复制相似问题