mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 12:03:33 +00:00
chore: always run proxy to virtualised Docker on macOS for 'image push' except OrbStack
This commit is contained in:
+14
-2
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user