Container exceeded memory limit CI/CD Origin: Build & delivery Last updated 25 Oct 2026

Bitbucket Pipelines: Container 'Build' exceeded memory limit / Docker container exited with code 137

A Bitbucket Pipelines step used more memory than the step allows (4 GB by default, 1 GB for service containers) and was killed.

Exact message you may see Container 'Build' exceeded memory limitContainer 'docker' exceeded memory limitBitbucket Pipelines exceeded memory limitBuild container exceeded memory limit

Meaning

Each step gets a memory allotment shared by the build container and services (Docker service defaults to 1 GB). Raise the size: 2x, tune the Docker service memory in definitions, or reduce the tool's memory use.

Common causes

  • Build tools (webpack, Gradle, tsc) exceeding the limit
  • Docker service container needing more than 1 GB
  • Many parallel processes in one step
  • Memory leak in tests
  • Services (databases) consuming the step's memory

⚡ Quick fix

  1. Use size: 2x on the step (doubles memory)
  2. Raise Docker memory in definitions: services: docker: memory: 3072
  3. Limit workers and heap size

Detailed fix by platform

Bitbucket Pipelines

  1. size: 2x costs double build minutes; set only on heavy steps

Code examples

Bigger step and Docker memory

yaml
definitions:
  services:
    docker:
      memory: 3072
pipelines:
  default:
    - step:
        size: 2x
        services: [docker]
        script:
          - docker build -t app .

How to diagnose

  1. Step — Which step was killed?
  2. Memory — Docker or build container?
  3. Workers — Parallelism reduced?

🔧 Still not fixed?

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

Where this error sits

Origin: Build & delivery. Errors that are often confused with or caused by this one (click to open):

Cannot connect to the Docker daemon (GitLab) — GitLab CI: Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running? (CI/CD)Cannot connect to the…Cannot find orb — CircleCI: Cannot find orb 'circleci/node@9.9.9'. Check the namespace and version exist (CI/CD)Cannot find orbComparisonError: manifest generation failed — Argo CD: ComparisonError: rpc error: code = Unknown desc = Manifest generation error (cached): kustomize build failed (CI/CD)ComparisonError: mani…Config compilation failed — CircleCI: Error calling workflow: 'build'. Cannot find a definition for job named test / Config does not conform to schema (CI/CD)Config compilation fa…Process completed with exit code 137 — GitHub Actions: Error: Process completed with exit code 137 (Killed — out of memory) (CI/CD)Process completed wit…Template file not found — Azure Pipelines: /azure-pipelines.yml: File /templates/build.yml not found in repository / Unable to find template (CI/CD)Template file not fou…Too long with no output — CircleCI: Too long with no output (exceeded 10m0s): context deadline exceeded (CI/CD)Too long with no outp…Waiting for next available executor — Jenkins: Still waiting to schedule task — Waiting for next available executor / 'agent1' is offline (CI/CD)Waiting for next avai…Container…

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.