Docker compose up 'Exec format error' loading a library
Someone reported same problem in this issue and his case was similar to yours. As discussed in comments, this worked for you, so I am posting this as answer also:
It sounds like it's trying to load a native extension that wasn't compiled for linux (in the container) -- maybe you previously installed the extension on OS X and it's trying to load that binary. If you mean this is a node app, try just removing node_modules and run npm install again
Fix that worked for you: rm -rf node_modules
Related videos on Youtube
Michele Minno
Fullstack developer, computer science teacher, beach volleyball and guitar player.
Updated on September 15, 2022Comments
-
Michele Minno over 1 year
I'm developing a multi-module docker nodejs app with docker-compose. There's an issue with the natural node package needed by a module. It seems that it can't exec it. I tried to rebuild it on the fly with a RUN command, but nothing changed. Here's the log when trying to run docker-compose up:
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)
Here's the 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" } }
My 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
I don't know whether it's an issue of this particular node package or a knowledge lack of mine. If I run the same application locally on my mac without docker, it doesn't encounter this problem.