Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Build failed with Container docker exceeded memory limit

sureshbabu_a March 24, 2023

Team,

 

I created a CI/CD pipeline for one of our micro service but it failed with the following error. 

node:14-alpine image is used to create docker image.  Moreover docker build took more than 30 minutes prior failing (it's too slow)


Error Message

Container 'docker' exceeded memory limit

 

Pipeline Code

pipelines:
branches:
Development:
- step:
name: Pre-requisite step
script:
- echo "No pre-requisites found"
- step:
name: Create docker image
         script:
          - echo "Creating docker image"
          - docker build -t microservice:$BITBUCKET_BUILD_NUMBER .
          services:
          - docker
          caches:
          - docker

 

I referred the following URL 

https://community.atlassian.com/t5/Bitbucket-questions/Container-Build-exceeded-memory-limit/qaq-p/1986822 

to fix the issue but unfortunately issue  is not resolved

 

I also tried by setting the following to increase the memory limit for docker service

definitions:
    services:
       docker:
           memory: 2048

and tried setting size: 2x in the pipeline but all failed with the same error

 

Kindly let me know had I missed anything

 

Thanks
Sathish Kumar

1 answer

0 votes
Oday Rafeh
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 24, 2023

Hi @sureshbabu_a 

The error message means that the Docker container used by your pipeline has run out of memory. This can happen if your pipeline is trying to build a large image or if your pipeline is running on a machine with limited resources.

You may need to further optimize your pipeline or use a machine with more resources.

Please try:

  • Split the Docker build process into smaller steps or use multi-stage builds to reduce the memory footprint of the build process.
  • Optimize your Dockerfile to reduce the size of the final image. You can use techniques such as removing unnecessary packages or compressing files to reduce the size of the image.
  • Use a machine with more memory or CPU resources to run your pipeline. You can try increasing the size of the machine or using a different machine type with more resources.
  • Consider using a container registry to store your Docker images instead of building them on the fly. This can reduce the build time and memory requirements of your pipeline.
sureshbabu_a March 24, 2023

Hi @Oday Rafeh 

 

Thank you for replying to my question.

 

As suggested. I would try to convert it to multi-stage docker image.  However, I've got another question.

 

"Use a machine with more memory or CPU resources to run your pipeline. You can try increasing the size of the machine or using a different machine type with more resources."   

 

How to select / use a different machine on BitBucket Cloud ?   Kindly let us know if it possible to use a different machine as we are a subscribed user.

 

Regards
Sathish Kumar

Oday Rafeh
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2023

Hi @sureshbabu_a ,

To use a different machine for your Bitbucket Cloud pipeline, you can use the "size" parameter in your pipeline configuration. This parameter allows you to specify the size of the machine that your pipeline runs on.

For example, you can use "size: 2x" to specify that your pipeline should run on a machine with double the resources of the default machine.

Here's an example pipeline configuration that sets the machine size to 2x:

pipelines:
default:
- step:
name: Build and test
size: 2x
script:
- echo "Building and testing..."

Note that not all sizes may be available in all regions, and larger sizes may come with additional costs. You can check the Bitbucket Cloud pricing page for more information.

I hope this helps! Let me know if you have any further questions.

Best regards,
Oday Rafeh

Like sureshbabu_a likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events