From 521ccf202681a273a2fd75cd368abcd97cb8aacb Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Thu, 9 Oct 2025 12:48:51 +1000 Subject: [PATCH] chore(push): run unregistry only if containerd image store enabled for docker --- internal/machine/machine.go | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/internal/machine/machine.go b/internal/machine/machine.go index 2fc63acd..8dec8eac 100644 --- a/internal/machine/machine.go +++ b/internal/machine/machine.go @@ -437,17 +437,26 @@ func (m *Machine) Run(ctx context.Context) error { var unreg *unregistry.Registry if m.config.ContainerdSockPath != "" { - // Create an embedded container registry listening on the machine IP address and - // using the local Docker (containerd) image store as its backend. - unreg, err = unregistry.NewRegistry(unregistry.Config{ - Addr: net.JoinHostPort(m.IP().String(), strconv.Itoa(constants.UnregistryPort)), - ContainerdNamespace: "moby", - ContainerdSock: m.config.ContainerdSockPath, - LogFormatter: "text", - LogLevel: "info", - }) + isContainerdStore, err := m.dockerService.IsContainerdImageStoreEnabled(ctx) if err != nil { - return fmt.Errorf("create embedded registry: %w", err) + return fmt.Errorf("check if Docker uses containerd image store: %w", err) + } + + if isContainerdStore { + // Create an embedded container registry listening on the machine IP address and + // using the local Docker (containerd) image store as its backend. + unreg, err = unregistry.NewRegistry(unregistry.Config{ + Addr: net.JoinHostPort(m.IP().String(), strconv.Itoa(constants.UnregistryPort)), + ContainerdNamespace: "moby", + ContainerdSock: m.config.ContainerdSockPath, + LogFormatter: "text", + LogLevel: "info", + }) + if err != nil { + return fmt.Errorf("create embedded registry: %w", err) + } + } else { + slog.Warn("Skipping embedded unregistry setup as Docker is not using the containerd image store.") } } else { slog.Warn("Skipping embedded unregistry setup as the containerd socket path is not configured.")