Skip to content

Commit c1985db

Browse files
authored
Cleanup docker images after use (#440)
We were only trying to prune dangling images, but not actually deleting images. This actually deletes the images after use.
1 parent e275ce1 commit c1985db

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: ci_test.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ def main():
7474

7575
print("Testing {}".format(dockerfile))
7676
sys.stdout.flush()
77-
log_file = dockerfile.replace("/", "_")
78-
log_file = "{}.log".format(log_file)
77+
image_name = dockerfile.replace("/", "_").replace("-", "_").lower()
78+
log_file = f'{dockerfile.replace("/", "_")}.log'
7979
cmd = [
8080
'docker', 'build', '--no-cache=true',
8181
'-f', dockerfile,
82+
'-t', image_name,
8283
docker_dir
8384
]
8485
if "buildx" in dockerfile:
@@ -92,6 +93,7 @@ def main():
9293
'--platform', 'linux/arm64,linux/amd64',
9394
'--no-cache=true',
9495
'-f', dockerfile,
96+
'-t', image_name,
9597
docker_dir
9698
]
9799

@@ -109,7 +111,8 @@ def main():
109111
run_command(cmd)
110112
print("[{}] - {}".format(results[dockerfile], dockerfile))
111113
sys.stdout.flush()
112-
run_command("docker image prune -f")
114+
run_command(f"docker image rm {image_name}")
115+
run_command("docker image prune -f")
113116

114117
for dockerfile in dockerfiles:
115118
if results[dockerfile] == "FAILED":

0 commit comments

Comments
 (0)