Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bitbucket pipeline shows error container 'docker ' exceeds memory limit

Shweta Khairnar April 9, 2025

Hello Team,

Facing the issue container 'docker' exceeded memory limit in Bitbucket pipeline even after mentioning size 2x for Sonarscan. We are using Bitbucket runners.

- step: &sonarscan
              name: SonarCloud Scan
              size: 2x  
              caches:
                  - sonar

Step size limit is set to 4096MB for small steps and for large steps 8192MB

Also, tried by increasing the docker service limit as below

definitions:
    services:
        docker:
            memory: 3072

And we have the limitation that we can't increase the memory above 3072.

Can anyone please help us with this.

 

Thanks in Advance!!

 

 

1 answer

0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 10, 2025

Hi Shweta,

You can't set a higher value than 3072 for small steps because 1GB is reserved for the build container (4096MB in total).

  • This means you can set the docker container memory to as high as 7168 for 2x steps (as they have a max of 8GB). 
  • More information regarding memory assignment for service containers may be found in our documentation: Databases and service containers 

If the docker container is still failing - you'll need to optimise your builds so that they don't use up that much memory, by addressing any memory leaks in the commands you're running.

  • You can add the following debug code above the line of code that's failing to determine how much memory the step is using, and which process is consuming the highest amount of CPU:

    - while true; do echo "Memory usage in bytes:" && cat /sys/fs/cgroup/memory.current; echo "Swap memory usage in bytes:" && cat /sys/fs/cgroup/memory.swap.current; sleep 2; done &

    - while true; do date && ps aux && echo "" && sleep 2; done &


  • More troubleshooting information for this specific issue may be found in our pipelines troubleshooting documentation:
    Pipeline build failed with Container “Docker” exceeded memory limit error 

 

Cheers!

- Ben (Bitbucket Cloud Support)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events