Building image failed with exit code: 137

The command returned a non-zero code: 137

Issue

Build step in pipeline fails with the following error:

The command 'XXXXXXX' returned a non-zero code: 137                                                          
[SYSTEM]                                                                                                                                  
 Message             Failed to build image: r.cfcr.io/<my-image>:my-tag                    
 Caused by           Container for step title: Building Docker Image, step type: build, operation: Building image                         
                     failed with exit code: 137 

Possible cause

This issue occurs where you are low on pipeline resources. The build step does not have enough memory to finish building. You can get an overview of your build resources by clicking in the metrics tab in the build screen.

Not enough memory

Not enough memory

The error usually happens when Docker does not have enough memory, but it can also appear if there is not enough disk space.

Solution

  • Set the build space for each pipeline build.
  • If that doesn’t work, you need to either simplify your application, for example, split it to microservices, or run the pipeline on a larger machine. For example if the build fails on a SMALL machine you should run it on a MEDIUM one.

    You can upgrade your account to get access to more resources by updating your Billing Settings in Codefresh.

Troubleshooting common issues