chore: always run proxy to virtualised Docker on macOS for 'image push' except OrbStack

This commit is contained in:
Pasha Sviderski
2026-02-23 20:06:23 +10:00
parent 14056cc584
commit fe56d6d708
+14 -2
View File
@@ -6,6 +6,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"net" "net"
"runtime"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@@ -363,14 +364,25 @@ func newUnregistryProxy(
return p, nil return p, nil
} }
// isDockerVirtualised checks if Docker is running in a virtualised environment like Docker Desktop on macOS. // isDockerVirtualised checks if Docker is running in a virtualised environment like Docker/Rancher Desktop or Colima.
// On macOS, Docker always requires a VM, so it returns true unless OrbStack is detected (which handles host networking
// natively). On other platforms, it checks for known virtualised Docker hostnames.
func isDockerVirtualised(ctx context.Context, dockerCli *docker.Client) (bool, error) { func isDockerVirtualised(ctx context.Context, dockerCli *docker.Client) (bool, error) {
info, err := dockerCli.Info(ctx) info, err := dockerCli.Info(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("get Docker info: %w", err) return false, fmt.Errorf("get Docker info: %w", err)
} }
virtualisedHostnames := []string{"docker-desktop", "colima", "lima-rancher-desktop"} // On macOS, Docker always runs in a VM. OrbStack is the only known exception that doesn't need a proxy.
if runtime.GOOS == "darwin" {
if info.Name == "orbstack" {
return false, nil
}
return true, nil
}
// On other platforms, check for known virtualised Docker environments.
virtualisedHostnames := []string{"docker-desktop", "rancher-desktop", "colima"}
for _, name := range virtualisedHostnames { for _, name := range virtualisedHostnames {
if strings.Contains(strings.ToLower(info.Name), name) { if strings.Contains(strings.ToLower(info.Name), name) {
return true, nil return true, nil