我正在做一个移动应用程序项目,有两个文件夹:
- 前端(8080作为本地端口)
- 后端,用Go编写
Docker中的每个文件夹都适合容器。
为了便于管理,我把这两个部分放在同一个文件夹里。
后端分成5个集装箱:
- mongo
- 复述,
- redis_commander (8082)
- mongo_express (8081) 后端(5000)
最后一个后端容器(5000)导致以下SASL错误:
/app/db/db.go:53 +0xbf
2021/07/22 10:15:15 Database:mongo:27017
panic: server returned error on SASL authentication step: BSON field 'saslContinue.mechanism' is an unknown field.
同时,我还:
- 删除容器、卷和映像
- 每个部件重新构建几次
- 审查我的配置文件,也与我的同事建立了系统
现在,我想知道我是否拼写错误或错过了一个参数在我的配置文件:
docker-compose.yml
version: '3.6'
services:
backend:
build:
context: ./src
restart: on-failure
ports:
- "5000:8080"
expose:
- 5000
networks:
- backend-network
depends_on:
- mongo
- redis
env_file:
- backend_config.env
mongo:
image: mongo
restart: on-failure
volumes:
- db-volume:/data/db
- dbconfig-volume:/data/configdb
networks:
- backend-network
env_file:
- db_config.env
mongo-express:
image: mongo-express
restart: on-failure
ports:
- 8081:8081
networks:
- backend-network
depends_on:
- mongo
env_file:
- db_config.env
redis:
image: redis:6.0.3-buster
restart: on-failure
networks:
- backend-network
redis-commander:
image: rediscommander/redis-commander:latest
restart: on-failure
ports:
- 8082:8082
networks:
- backend-network
depends_on:
- redis
environment:
- REDIS_HOST=redis
- PORT=8082
volumes:
db-volume:
dbconfig-volume:
networks:
backend-network:
backend_config.env
MONGODB_USERNAME=root
MONGODB_PASSWORD=example
DATABASE=mongo:27017
DATABASE_NAME=admin
ACCESS_SECRET=abc
REFRESH_SECRET=xyz
db_config.env
MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=example
ME_CONFIG_MONGODB_ADMINUSERNAME=root
ME_CONFIG_MONGODB_ADMINPASSWORD=example
ME_CONFIG_MONGODB_SERVER=mongo
ME_CONFIG_MONGODB_PORT=27017
我也有这些消息与蒙古快递集装箱:
(node:8) [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.
basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
(node:8) [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.
Could not connect to database using connectionString: mongodb://root:example@mongo:27017/"
(node:8) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [mongo:27017] on first connect [Error: getaddrinfo EAI_AGAIN mongo
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26) {
name: 'MongoNetworkError'
}]
at Pool.<anonymous> (/node_modules/mongodb/lib/core/topologies/server.js:441:11)
at Pool.emit (events.js:314:20)
at /node_modules/mongodb/lib/core/connection/pool.js:564:14
at /node_modules/mongodb/lib/core/connection/pool.js:999:11
at /node_modules/mongodb/lib/core/connection/connect.js:32:7
at callback (/node_modules/mongodb/lib/core/connection/connect.js:283:5)
at Socket.<anonymous> (/node_modules/mongodb/lib/core/connection/connect.js:313:7)
at Object.onceWrapper (events.js:421:26)
at Socket.emit (events.js:314:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:8) 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)
(node:8) [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.
(node:8) [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.
Could not connect to database using connectionString: mongodb://root:example@mongo:27017/"
(node:8) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [mongo:27017] on first connect [Error: connect ECONNREFUSED 172.18.0.5:27017
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) {
name: 'MongoNetworkError'
}]
at Pool.<anonymous> (/node_modules/mongodb/lib/core/topologies/server.js:441:11)
at Pool.emit (events.js:314:20)
at /node_modules/mongodb/lib/core/connection/pool.js:564:14
at /node_modules/mongodb/lib/core/connection/pool.js:999:11
at /node_modules/mongodb/lib/core/connection/connect.js:32:7
at callback (/node_modules/mongodb/lib/core/connection/connect.js:283:5)
at Socket.<anonymous> (/node_modules/mongodb/lib/core/connection/connect.js:313:7)
at Object.onceWrapper (events.js:421:26)
at Socket.emit (events.js:314:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:8) 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)
(node:8) [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.
(node:8) [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.
提前谢谢你。
我得到了这个错误,在我的情况下,这是一个版本不匹配的蒙古进口。我正在安装的系统上安装了Ubuntu(21)发行版apt版本,该版本有"build -without-version-string"(什么?)我的话)为mongoimport——version。我安装了最新的100.5.0版本,错误消失了。
因此,即使您没有使用mongoimport,如果版本不匹配,此错误也可能在使用其他mongoutils时发生。