From e8b4dd0bd1961b5ad335659b5af71ea0fd0e87c6 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Thu, 9 Oct 2025 12:11:18 +1000 Subject: [PATCH] chore(push): fail 'image push' when containerd image store not used on target machine --- pkg/client/image.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/client/image.go b/pkg/client/image.go index 5acd6d2b..161cd76c 100644 --- a/pkg/client/image.go +++ b/pkg/client/image.go @@ -215,6 +215,26 @@ func (cli *Client) pushImageToMachine( platform *ocispec.Platform, ) error { pw := progress.ContextWriter(ctx) + boldStyle := lipgloss.NewStyle().Bold(true) + pushEventID := fmt.Sprintf("Pushing %s to %s", boldStyle.Render(imageName), boldStyle.Render(machine.Name)) + + // Check the Docker image store type on the target machine. + images, err := cli.ListImages(ctx, api.ImageFilter{ + Machines: []string{machine.Id}, + Name: "%invalid-name-to-only-check-store-type%", + }) + if err != nil { + return fmt.Errorf("check Docker image store type on machine '%s': %w", machine.Name, err) + } + + // Only support Docker with containerd image store enabled to avoid the confusion of pushing images to containerd + // and then not being able to see and use them in Docker. + if !images[0].ContainerdStore { + pw.Event(progress.NewEvent(pushEventID, progress.Error, "containerd image store required")) + return fmt.Errorf("docker on machine '%s' is not using containerd image store, "+ + "which is required for pushing images. Follow the instructions to enable it: "+ + "https://docs.docker.com/engine/storage/containerd/", machine.Name) + } machineSubnet, _ := machine.Network.Subnet.ToPrefix() machineIP := network.MachineIP(machineSubnet) @@ -225,7 +245,6 @@ func (cli *Client) pushImageToMachine( return fmt.Errorf("get proxy dialer: %w", err) } - boldStyle := lipgloss.NewStyle().Bold(true) proxyEventID := fmt.Sprintf("Proxy to unregistry on %s", boldStyle.Render(machine.Name)) pw.Event(progress.StartingEvent(proxyEventID)) @@ -297,7 +316,6 @@ func (cli *Client) pushImageToMachine( } // Push the image through the proxy. - pushEventID := fmt.Sprintf("Pushing %s to %s", boldStyle.Render(imageName), boldStyle.Render(machine.Name)) pw.Event(progress.NewEvent(pushEventID, progress.Working, "Pushing")) pushCh, err := dockerCli.PushImage(ctx, pushImageTag, image.PushOptions{