huggingface / chat-ui

Open source codebase powering the HuggingChat app
https://huggingface.co/chat
Apache License 2.0
7.12k stars 1.03k forks source link

chat-ui docker image failed to connect the mongo docker contrainer #650

Open walkacross opened 8 months ago

walkacross commented 8 months ago

step 1: build the chat-ui image

docker build -t chat-ui  -f ./Dockerfile.local .

step 2:

# bind the 27016
docker run -d -p 27016:27017 --name mongo-chatui mongo:latest

step 3: run a contrainer

# add a .env.local config
MONGODB_URL=mongodb://localhost:27016
HF_TOKEN=<your access token>
docker run --rm --mount type=bind,source="$(pwd)/.env.local",target=/app/.env.local -p 3000:3000 chat-ui

results: when load localhost:3000

MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27016
at Timeout._onTimeout (/app/node_modules/mongodb/lib/sdam/topology.js:278:38)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { 'localhost:27016' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined,
[Symbol(errorLabels)]: Set(0) {}
}
MongoTopologyClosedError: Topology is closed
at /app/node_modules/mongodb/lib/sdam/topology.js:218:46 {
[Symbol(errorLabels)]: Set(0) {}
}
MongoTopologyClosedError: Topology is closed
at processWaitQueue (/app/node_modules/mongodb/lib/sdam/topology.js:514:46)
at Topology.selectServer (/app/node_modules/mongodb/lib/sdam/topology.js:283:9)
at Topology.<anonymous> (/app/node_modules/mongodb/lib/sdam/topology.js:42:94)
at node:internal/util:442:7
at new Promise (<anonymous>)
at Topology.selectServerAsync (node:internal/util:428:12)
at executeOperationAsync (/app/node_modules/mongodb/lib/operations/execute_operation.js:74:35)
at /app/node_modules/mongodb/lib/operations/execute_operation.js:12:45
at maybeCallback (/app/node_modules/mongodb/lib/utils.js:293:21)
at executeOperation (/app/node_modules/mongodb/lib/operations/execute_operation.js:12:38) {
[Symbol(errorLabels)]: Set(0) {}
}

@nsarrazin

nsarrazin commented 8 months ago

Hi 👋 Do you have a DB running locally in another container ? If so you need to make it accessible from inside the docker container see here

If you don't have a DB running, you can use the chat-ui-db image instead, in order to have it built-in.

walkacross commented 8 months ago

Hi 👋 Do you have a DB running locally in another container ? If so you need to make it accessible from inside the docker container see here

If you don't have a DB running, you can use the chat-ui-db image instead, in order to have it built-in.

hi, thanks for yourkind reply. I solved this problem by set the --network argument in docker command.

It's would be better if the chat-ui readme complete docker command to make chat-ui really runnable. considering the 27017 port of the host might have been used.

guidevops commented 7 months ago

Looks like the image is build with the variables ? Anyway that i can build the images without vars and set when starting the container ?

HaoRenkk123 commented 2 weeks ago

嗨 👋 您是否在另一个容器中本地运行数据库?如果是,您需要使其从 docker 容器内部可访问,请参见此处 如果您没有运行数据库,chat-ui-db则可以使用图像来将其内置。

嗨,谢谢你的回复。我通过在docker命令中设置--network参数解决了这个问题。

如果 chat-ui readme 有完整的 docker 命令可以让 chat-ui 真正运行,那就更好了。 考虑到主机的 27017 端口可能已经被使用。

so,the --network add where?run chatui image or run mangodb image?