taskcat icon indicating copy to clipboard operation
taskcat copied to clipboard

Add rm=True to docker build to reduce disk usage

Open sudoudaisuke opened this issue 1 month ago • 0 comments

Summary

Add rm=True parameter to docker.APIClient().build() to automatically remove intermediate containers after each layer is created.

Problem

Currently, TaskCat leaves intermediate containers after Docker builds, consuming significant disk space:

  • ~225MB of intermediate containers per build
  • Containers accumulate across multiple builds
  • Problematic in disk-constrained environments (e.g., AWS CloudShell with 1GB limit)

Solution

Set rm=True in the build() method to remove intermediate containers immediately after each layer image is created.

Benefits

  • Reduces disk usage by ~30% (from 740MB to 515MB in test case)
  • Prevents container accumulation across multiple builds
  • Layer images are still preserved (no loss of functionality)
  • Better user experience in resource-constrained environments

Testing

Tested on AWS CloudShell (1GB disk limit) building a Go Lambda function (cfn-ecr-aws-soci-index-builder) with the following results:

Before (rm=False):

sudoudaisuke avatar Nov 11 '25 08:11 sudoudaisuke