did not complete successfully 🐳 Docker

failed to solve: process "/bin/sh -c ..." did not complete successfully: exit code: 1

A RUN step in your Dockerfile failed. The real error is printed in the lines just above this message.

Seen on: Docker

Meaning

BuildKit stops at the first RUN command that exits non-zero and reports it with this generic line (the legacy builder says “The command '/bin/sh -c …' returned a non-zero code”). Scroll up for the actual failure: npm/pip errors, missing packages, network/DNS, or out-of-memory (exit code 137).

Common causes

  • The command itself failed (npm install, pip install, make)
  • apt/apk package not found (missing apt-get update)
  • No network/DNS during build
  • Build runs out of memory (exit code 137)
  • Command assumes a file not copied yet

⚡ Quick fix

  1. Read the log above the error, or rebuild with --progress=plain --no-cache
  2. Run the failing command in an interactive container from the previous stage
  3. Combine apt-get update && apt-get install in one RUN

Detailed fix by platform

Docker

  1. docker build --progress=plain --no-cache -t app . 2>&1 | tail -60

Dockerfile

  1. bash
    RUN apt-get update && apt-get install -y --no-install-recommends curl \\
     && rm -rf /var/lib/apt/lists/*

How to diagnose

  1. Real error — Lines just before "did not complete successfully"
  2. Exit code — 1 (command), 127 (not found), 137 (OOM)
  3. Reproduce — docker run -it <base> sh and run the step

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.