'Kaniko build fails with additional RUN commands in the build context

I am working on a project which requires me to build and push images to AWS ECR using a Fargate cluster. I pass the Dockerfile as build context to a Fargate task which then gets executed in a container. However, my build fails when I try to run some commands. For example, the following Dockerfile:

FROM node:latest
RUN npm install -g npm-check-updates
RUN ncu --version
RUN ncu -u

The first two runs are successful. If I omit the last RUN, the image is built and pushed successfully, I see the ncu version printed in the logs. However, if I try to execute ncu -u, the built fails with error ncu -u command not found. Is there something I am missing here? Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source