Docker组装'Exec格式错误'加载一个库

我正在用docker-compose开发一个多模块docker nodejs应用程序。 模块需要的自然节点包有个问题。 看来它不能执行它。 我试图用RUN命令重新编译它,但没有任何改变。 以下是试图运行docker-compose的日志:

web_1 | /app/web-server/node_modules/natural/lib/natural/classifiers/classifier.js:32 web_1 | if (e.code !== 'MODULE_NOT_FOUND') throw e; web_1 | ^ web_1 | web_1 | Error: Error loading shared library /app/web-server/node_modules/webworker-threads/build/Release/WebWorkerThreads.node: Exec format error web_1 | at Error (native) web_1 | at Object.Module._extensions..node (module.js:597:18) web_1 | at Module.load (module.js:487:32) web_1 | at tryModuleLoad (module.js:446:12) web_1 | at Function.Module._load (module.js:438:3) web_1 | at Module.require (module.js:497:17) web_1 | at require (internal/module.js:20:19) web_1 | at bindings (/app/web-server/node_modules/bindings/bindings.js:81:44) web_1 | at Object.<anonymous> (/app/web-server/node_modules/webworker-threads/index.js:1:105) web_1 | at Module._compile (module.js:570:32) web_1 | at Object.Module._extensions..js (module.js:579:10) web_1 | at Module.load (module.js:487:32) web_1 | at tryModuleLoad (module.js:446:12) web_1 | at Function.Module._load (module.js:438:3) web_1 | at Module.require (module.js:497:17) web_1 | at require (internal/module.js:20:19) 

这里是package.json:

 { "name": "realaffinities", "version": "1.0.0", "description": "", "main": "server/Server.js", "keywords": [], "author": "", "license": "GPL-3.0", "dependencies": { "async": "^2.5.0", "big-integer": "^1.6.23", "body-parser": "1.9.0", "express": "^4.15.3", "express-validator": "^3.2.1", "knex": "^0.13.0", "mysql": "^2.14.1", "natural": "^0.5.4", "twit": "^2.2.9", "url-exists": "^1.0.3", "nodemon": "^1.11.0" }, "devDependencies": { "grunt": "^1.0.1", "grunt-express-server": "^0.5.3", "mocha": "^3.4.2", "supertest": "^3.0.0", "bcrypt": "1.0.2" }, "scripts": { "test": "mocha web-server/test", "start": "node server/Server.js" } } 

我的dockerfile:

 FROM node:6.11-alpine EXPOSE 3000 ENV NODE_ENV development RUN mkdir /app WORKDIR /app # add package.json and run npm install before adding the rest of the files # this way, you only run npm install when package.json changes ADD /web-server/package.json /app/package.json RUN apk add --no-cache make gcc g++ python RUN npm install -g mocha RUN npm install 

我不知道这是一个特定的节点包还是我的知识缺乏的问题。 如果我在没有docker的mac上本地运行相同的应用程序,它不会遇到这个问题。

有人在这个问题上报告了同样的问题,他的情况与你的情况类似。 正如在评论中所讨论的,这对你有用,所以我发布这个答案也是:

这听起来像是试图加载一个本地扩展,而不是为Linux编译(在容器中) – 也许你以前在OS X上安装了扩展,它试图加载该二进制文件。 如果你的意思是这是一个节点的应用程序,尝试只是删除node_modules并再次运行npm安装