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.
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
- Use
size: 2xon the step (doubles memory) - Raise Docker memory in
definitions: services: docker: memory: 3072 - Limit workers and heap size
Detailed fix by platform
Bitbucket Pipelines
size: 2xcosts double build minutes; set only on heavy steps
Code examples
Bigger step and Docker memory
definitions:
services:
docker:
memory: 3072
pipelines:
default:
- step:
size: 2x
services: [docker]
script:
- docker build -t app .How to diagnose
- Step — Which step was killed?
- Memory — Docker or build container?
- 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:
Similar errors
- Cannot connect to the Docker daemon (GitLab) GitLab CI: Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
- Cannot find orb CircleCI: Cannot find orb 'circleci/node@9.9.9'. Check the namespace and version exist
- ComparisonError: manifest generation failed Argo CD: ComparisonError: rpc error: code = Unknown desc = Manifest generation error (cached): kustomize build failed
Most viewed in CI/CD
- The process '/usr/bin/git' failed with exit code 128 GitHub Actions: Error: The process '/usr/bin/git' failed with exit code 128
- This job is stuck because you don't have any active runners GitLab CI: This job is stuck because you don't have any active runners online or available with any of these tags assigned to them
- Resource not accessible by integration GitHub Actions: Error: Resource not accessible by integration (403)
Other ways to find it
Where this error sits
Origin: Build & delivery. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 25 Oct 2026