node.jsdockerexpressmongooseportainer

Unreachable code when connecting to mongoDB


I am trying to dockerize my node.js app and it just won't work. I narrowed the point of error down to two lines, but I just can't get to the ground of the problem. I'll share my code if you need more just ask for it. I am using a raspberry pi 3 to deploy my container unsing portainer. Maybe I missed a setting there idk.

NOTE: When I try to run it on my PC with the arm emulator in docker desktop it WILL run but just not on my pi.

console.log("Hello from the docker3")

//Database
const mongoose = require("mongoose");

mongoose.connect(
  `mongodb+srv://{process.env.DB_USER}:${process.env.DB_PASSWORD}@${process.env.DB_ADDRESS}/`
);
console.log("Hello from the docker4")

The rest of the code are just some webpages that get sent and some express.js stuff.

My error

I am getting this error from this part, you can see that the print number 4 doesn't get printed so I think it's somewhere there

I searched everywhere but I couldn't find a reason for this.


Solution

  • By updating my pi to arm64 it fixed itself, I also used a docker compose that also downloaded the mongo image (mongo is only arm64). This fixxed it, it was just a issue with the 32-bit version of the OS i had on my pi