Skip to content

Commit c719c92

Browse files
committed
fix: remove both short and fully-qualified Docker image names before building
BuildKit uses fully-qualified image names (docker.io/library/...) during the export phase, which was causing 'already exists' errors even after removing the short image name. Now both name formats are removed to ensure clean builds.
1 parent 3b506dd commit c719c92

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

packages/dependency-installer/tests/containers/image_builder.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,24 @@ impl ImageBuilder {
7575

7676
info!(image = full_image_name, "Building Docker image...");
7777

78-
// Remove any stale/corrupt image that might exist but wasn't detected
79-
// This fixes CI issues where Docker BuildKit reports "already exists" during export
78+
// Remove any stale/corrupt image that might exist but wasn't detected.
79+
// This fixes CI issues where Docker BuildKit reports "already exists" during export.
80+
// We remove both the short name and the fully-qualified name that BuildKit uses.
8081
drop(
8182
Command::new("docker")
8283
.arg("rmi")
8384
.arg("-f")
8485
.arg(&full_image_name)
8586
.output(), // Ignore errors - image might not exist
8687
);
88+
let fq_image_name = format!("docker.io/library/{full_image_name}");
89+
drop(
90+
Command::new("docker")
91+
.arg("rmi")
92+
.arg("-f")
93+
.arg(&fq_image_name)
94+
.output(), // Ignore errors - image might not exist
95+
);
8796

8897
// Build the image with --force-rm to clean up intermediate containers
8998
let output = Command::new("docker")

src/testing/e2e/containers/image_builder.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,18 @@ impl ContainerImageBuilder {
305305

306306
// In CI environments, Docker `BuildKit` may have stale tags or cache conflicts.
307307
// Force remove any existing image before building to ensure a clean build state.
308+
// We remove both the short name and the fully-qualified name that BuildKit uses.
308309
drop(
309310
Command::new("docker")
310311
.args(["rmi", "-f", &image_tag])
311312
.output(),
312313
);
314+
let fq_image_tag = format!("docker.io/library/{image_tag}");
315+
drop(
316+
Command::new("docker")
317+
.args(["rmi", "-f", &fq_image_tag])
318+
.output(),
319+
);
313320

314321
info!(
315322
image_name = %image_name,

0 commit comments

Comments
 (0)