INNER CODE UNIT · Go

isDockerProviderAvailable

ddev/ddev · winpkg/installer_test.go:763

func isDockerProviderAvailable(distroName string) bool {
	// Check if docker ps works in the distro
	_, err := exec.RunHostCommand("wsl.exe", "-d", distroName, "docker", "ps")
	return err == nil
}

// windowsPathToWSL converts a Windows path to its WSL2 mount path in Go,
// avoiding the need to call wslpath (which receives args through bash and
// has backslashes stripped as escape sequences).
// Example: C:\Users\testbot\AppData\Local\mkcert → /mnt/c/Users/testbot/AppData/Local/mkcert
func windowsPathToWSL(winPath string) string {
	if len(winPath) >= 2 && winPath[1] == ':' {
		drive := strings.ToLower(string(winPath[0]))
		rest := strings.ReplaceAll(winPath[2:], "\\", "/")
		return "/mnt/" + drive + rest
	}
	return strings.ReplaceAll(winPath, "\\", "/")
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…