Skip to content

Commit

Permalink
fix: prune stopped containers after build
Browse files Browse the repository at this point in the history
  • Loading branch information
aliciaaevans committed Dec 13, 2024
1 parent 1ac7c15 commit dce9c89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bioconda_utils/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str],
# remove traces of the build
if not keep_old_work:
conda_build_purge()
# prune stopped containers
if docker_builder is not None:
docker_utils.pruneStoppedContainers()

if failed or failed_uploads:
logger.error('BUILD SUMMARY: of %s recipes, '
Expand Down Expand Up @@ -525,4 +528,4 @@ def report_resources(message, show_docker=True):
logger.info("{0} Free disk space: {1:.2f} MB. Free memory: {2:.2f} MB ({3:.2f}%)".format(message, free_space_mb, free_mem_mb, free_mem_percent))
if show_docker:
cmd = ['docker', 'system', 'df']
utils.run(cmd, mask=False, live=True)
utils.run(cmd, mask=False, live=True)
5 changes: 5 additions & 0 deletions bioconda_utils/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,8 @@ def purgeImage(mulled_upload_target, img):
pkg_container_image = f"quay.io/{mulled_upload_target}/{pkg_name}:{pkg_version}--{pkg_build_string}"
cmd = ['docker', 'rmi', pkg_container_image]
o = utils.run(cmd, mask=False)


def pruneStoppedContainers():
cmd = ['docker', 'container', 'prune', '-f']
utils.run(cmd, mask=False)

0 comments on commit dce9c89

Please sign in to comment.