Home > Mobile >  Docker container keeps failing when run in Kubernetes (npm error EISDIR)
Docker container keeps failing when run in Kubernetes (npm error EISDIR)

Time:12-30

I am running the following command to start a k8s pod

kubectl run api --image=corina1998/api --env="PORT=3000"

And I get the following error in the pods' logs of my api service. This is the output of kubectl logs api command:

> [email protected] start-docker /usr/src/app
> node src/start.js

internal/fs/utils.js:332
    throw err;
    ^
Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (fs.js:617:3)
    at tryReadSync (fs.js:382:20)
    at Object.readFileSync (fs.js:419:19)
    at /usr/src/app/node_modules/docker-secret/dist/index.js:16:18
    at Array.forEach (<anonymous>)
    at getSecrets (/usr/src/app/node_modules/docker-secret/dist/index.js:12:15)
    at Object.<anonymous> (/usr/src/app/node_modules/docker-secret/dist/index.js:30:19)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32) {
  errno: -21,
  syscall: 'read',
  code: 'EISDIR'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start-docker: `node src/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start-docker script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

What could be the problem and how could I debug?

CodePudding user response:

I solved this weird problem by removing package-lock.json, rerun npm install to generate a new package-lock.json file, then I rebuilt the image and now it works. I use previously a combination of yarn install and npm install with affected my package-lock.json file.

  • Related