我的node.JS应用程序在docker容器中运行。虽然此设置的大多数功能正常但它无法与kafka-node模块一起使用。抛出的异常是
/app/node_modules/kafka-node/node_modules/snappy/node_modules/bindings/bindings.js:83
throw e
^
Error: Module did not self-register.
at Error (native)
at Object.Module._extensions..node (module.js:434:18)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at bindings (/app/node_modules/kafka-node/node_modules/snappy/node_modules/bindings/bindings.js:76:44)
at Object.<anonymous> (/app/node_modules/kafka-node/node_modules/snappy/snappy.js:2:34)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
我的Dockerfile如下
FROM node:4
RUN mkdir -p /app
WORKDIR /app
COPY package.json /app/package.json
RUN npm cache clean
RUN npm install
RUN npm rebuild
COPY . /app
EXPOSE 8085
CMD []
ENTRYPOINT ["bash", "runscript.sh"]
有关详细信息,Kafka正在单独的服务器上运行。打开所有相关端口,我可以成功远程登录以进行检查。