Skip to content

Commit

Permalink
fix: prune stopped containers after build (#1025)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Dale <[email protected]>
  • Loading branch information
aliciaaevans and daler authored Dec 14, 2024
1 parent 1ac7c15 commit 3a178ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 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,6 @@ 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)
cmd = ['docker', 'ps', '-a']
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 3a178ef

Please sign in to comment.