Lesstep
Bitbucket Cloud · Pipelines · Checked October 29, 2026

Bitbucket Pipelines: "Container 'Build' exceeded memory limit."

Bitbucket stopped the step from outside: the build container, where your script runs, used more memory than the step left it. The command that was running when it happened did not fail by itself, so its last lines in the log often say nothing useful. Find what used the memory, cap it, or give the build container more.

Where the memory goes

From Atlassian's Step options and Databases and service containers:

The same sizes apply on Linux Docker self-hosted runners. Shell runners (Windows PowerShell, macOS, Linux shell) use all the memory of their machine.

1. See what grows

Atlassian's article on this message (Bitbucket Pipelines build fails: "Container 'Build' exceeded memory limit") suggests two background loops at the start of the failing step's script. They print the container's memory use and the process list into the step's log while the real commands run:

- step:
    script:
      - while true; do echo "Memory usage in bytes:" && cat /sys/fs/cgroup/memory.current; sleep 2; done &
      - while true; do date && ps aux && echo "" && sleep 2; done &
      - npm ci
      - npm test

The last numbers before the step stops show how close it came, and the process list shows which one was large. Atlassian also suggests running the build locally in the same image, on Linux, to see whether it needs that much memory anywhere.

2. Cap the tool that grows

3. Give the build container more

The sizes, from Step options: 1x 4 GB, 2x 8 GB, 4x 16 GB, 8x 32 GB, 16x 64 GB, 24x 96 GB, 32x 128 GB. 4x and above are only for Standard and Premium plans. Each size uses that many times the build minutes of 1x: a 4x step four times.

If it says 'docker' instead of 'Build'

"Container 'docker' exceeded memory limit." is the docker service, which keeps 1024 MB whatever the step size. See how to give the docker service more memory.

Bitbucket Pipelines in IntelliJ IDEA

Pipeline Inbox for Bitbucket Pipelines, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the pipelines of all your Bitbucket Cloud repositories in an IDE tool window, with their steps, the failed step and the command it stopped at. A running step's log grows in the IDE as Bitbucket writes it, so the memory lines above can be watched without the browser. The list, steps and logs are free; running, re-running and stopping pipelines are Pro (US$1.50 a month, with a 30-day trial).

Get it on JetBrains Marketplace

Atlassian, Bitbucket and Bitbucket Pipelines are trademarks of Atlassian; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Atlassian or JetBrains.

More: Pipelines did not run after a push · "Container 'docker' exceeded memory limit." · "Exceeded build time limit of 120 minutes" · The cache is not used · "unexpected system error" · "command not found" · Submodules not cloned · "We couldn't clone the repository" · "No online runner available" · "No space left on device" · "Step exceeded processing limits" · The artifact is missing in the next step · The build passed before and fails now · Build setup takes too long · "You've run out of build minutes" · "Permission denied to update branch" · "You have reached your pull rate limit" (Docker Hub) · "There is an error in your bitbucket-pipelines.yml" · "This pipeline was paused" (deployments) · Bitbucket Pipelines plugins for IntelliJ IDEA, compared · 日本語