Search code examples
node.jsdockerkubernetesnext.js

nextjs on kubernetes fails to start


Developed a nextjs app and have deployed it to a kubernetes (AKS) cluster. The docker file looks pretty much identical to the sample nextjs docker files (see here).

The pod manifest is nothing special either, all I'm doing is setting some environment variables and setting the container up with the right docker image.

The nextjs app refuses to start on a pod in the AKS cluster.

I have pulled the docker image from the container registry and am able to start it up locally on docker desktop - all works fine.

However, it refuses to start on a kubernetes pod, and I am at my wits end! I overrode the entry point to the container on the pod and have manually tried running node server.js via kubectl inside the container, and... nothing happens. Node just exits after a second which seems to indicate that something is causing nodejs to silently crash.

What could be going wrong here? Is there anyway for me to get more output to try and diagnose this issue?


Solution

  • Ok, seems like running operations and the final command as nextjs USER as specified in the Dockerfile is the bit that's causing issues in kubernetes. Removing those and running as default, root user fixes the issues.