**Creating a Docker container from an image that runs SQlite resulting in errors on an ARM architecture M1 pro macbook
**
This is one of two dockerfiles. The front-end dockerfile runs fine. This dockerfile aims to run express.js (back-end) which talks to the Database (db.js).
Dockerfile
FROM node:14
# Install system dependencies
RUN apt-get update &&
apt-get install -y
python3
make
g++
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install dependencies
RUN npm install
# Rebuild SQLite3 module
RUN npm rebuild keinos/sqlite3 --build-from-source
# Copy the rest of the application code
COPY . .
# Command to run the application
CMD ["node", "express.js"]
docker run -d --name pizzaserver3 -p 3004:3004 pizza-server
Log output:
2024-06-16 23:37:26 /app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:57
2024-06-16 23:37:26 throw err;
2024-06-16 23:37:26 ^
2024-06-16 23:37:26
2024-06-16 23:37:26 Error: /app/node_modules/sqlite3/build/Release/node_sqlite3.node: invalid ELF header
2024-06-16 23:37:26 at Object.Module._extensions..node (internal/modules/cjs/loader.js:1173:18)
2024-06-16 23:37:26 at Module.load (internal/modules/cjs/loader.js:979:32)
2024-06-16 23:37:26 at Function.Module._load (internal/modules/cjs/loader.js:819:12)
2024-06-16 23:37:26 at Module.require (internal/modules/cjs/loader.js:1003:19)
2024-06-16 23:37:26 at require (internal/modules/cjs/helpers.js:107:18)
2024-06-16 23:37:26 at bindings (/app/node_modules/bindings/bindings.js:112:48)
2024-06-16 23:37:26 at Object.<anonymous> (/app/node_modules/sqlite3/lib/sqlite3-binding.js:1:37)
2024-06-16 23:37:26 at Module._compile (internal/modules/cjs/loader.js:1114:14)
2024-06-16 23:37:26 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
2024-06-16 23:37:26 at Module.load (internal/modules/cjs/loader.js:979:32) {
2024-06-16 23:37:26 code: 'ERR_DLOPEN_FAILED'
2024-06-16 23:37:26 }
2024-06-16 23:37:35 /app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:57
2024-06-16 23:37:35 throw err;
2024-06-16 23:37:35 ^
2024-06-16 23:37:35
2024-06-16 23:37:35 Error: /app/node_modules/sqlite3/build/Release/node_sqlite3.node: invalid ELF header
2024-06-16 23:37:35 at Object.Module._extensions..node (internal/modules/cjs/loader.js:1173:18)
2024-06-16 23:37:35 at Module.load (internal/modules/cjs/loader.js:979:32)
2024-06-16 23:37:35 at Function.Module._load (internal/modules/cjs/loader.js:819:12)
2024-06-16 23:37:35 at Module.require (internal/modules/cjs/loader.js:1003:19)
2024-06-16 23:37:35 at require (internal/modules/cjs/helpers.js:107:18)
2024-06-16 23:37:35 at bindings (/app/node_modules/bindings/bindings.js:112:48)
2024-06-16 23:37:35 at Object.<anonymous> (/app/node_modules/sqlite3/lib/sqlite3-binding.js:1:37)
2024-06-16 23:37:35 at Module._compile (internal/modules/cjs/loader.js:1114:14)
2024-06-16 23:37:35 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
2024-06-16 23:37:35 at Module.load (internal/modules/cjs/loader.js:979:32) {
2024-06-16 23:37:35 code: 'ERR_DLOPEN_FAILED'
2024-06-16 23:37:35 }
Tried various methods
- changing Node to Alpine version, to not affect
New contributor
ramonz000 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.