ProjectStack
docker

The command '/bin/sh -c RUN_COMMAND' returned a non-zero code: 1

A RUN instruction in your Dockerfile executed a shell command that failed — the command exited with a non-zero status code, which Docker treats as a build failure. The build stops at the failed layer and doesn't produce an image.

Common causes

  • A package install failed (apt-get, npm install, pip install) due to a missing dependency or network issue
  • A command references a binary or script that doesn't exist in the base image at that point in the build
  • A compilation or build step inside the container failed due to missing libraries or code errors
  • Shell syntax error in the RUN instruction — missing quotes, wrong escaping, or bad pipe handling

How to fix it

  1. Add --no-cache to see the full error: docker build --no-cache -t myapp . then read the output above the 'returned a non-zero code' line
  2. Run the failing command interactively: docker run -it base-image /bin/sh, then run the command manually
  3. For apt-get failures: ensure you run apt-get update before apt-get install in the same RUN layer
  4. Chain commands with && so failures stop the layer: RUN apt-get update && apt-get install -y curl

Example

$ docker build . Step 4/8 : RUN npm install ---> Running in 3f2c1b9a0d7e npm ERR! missing package.json The command '/bin/sh -c npm install' returned a non-zero code: 1

npm install fails because package.json wasn't copied into the container before this RUN step

Browse more errors

The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.