Skip to content

Conversation

@simonferquel
Copy link
Contributor

Socket path detection now checks WSL2 path (/mnt/wsl/docker-desktop/shared-sockets/host-services/backend.sock) between LinuxKit and native Linux checks in pkg/desktop/sockets_linux.go.

@simonferquel simonferquel requested a review from a team as a code owner January 16, 2026 14:48
@simonferquel
Copy link
Contributor Author

/review

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Good addition for WSL2 support! The change correctly adds detection for the WSL2 Docker Desktop socket path between LinuxKit and native Linux checks. The refactored control flow is clearer and handles the priority order well.

Reviewed Areas

  • Correctness: Logic flow is correct with proper priority ordering
  • Error Handling: Proper use of errors.Is for non-ErrNotExist errors
  • ⚠️ Testing: No tests exist for this function
  • Idiomatic Go: Follows Go conventions

Minor Suggestions

See inline comments for potential improvements around error handling consistency and code maintainability.


// On Linux
if _, err = os.Stat("/mnt/wsl/docker-desktop/shared-sockets/host-services/backend.sock"); err == nil {
// Inside WSL2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY Violation: This error check pattern if !errors.Is(err, os.ErrNotExist) is repeated twice (lines 18-20 and 29-31). Consider extracting it:

if err := checkNotExist(err); err != nil {
    return DockerDesktopPaths{}, err
}

func checkNotExist(err error) error {
    if err != nil && !errors.Is(err, os.ErrNotExist) {
        return err
    }
    return nil
}

Or simply reuse the err variable:

_, err = os.Stat("/mnt/wsl/docker-desktop/shared-sockets/host-services/backend.sock")
if err == nil {
    return DockerDesktopPaths{...}, nil
}
if !errors.Is(err, os.ErrNotExist) {
    return DockerDesktopPaths{}, err
}

}

// On Linux
if _, err = os.Stat("/mnt/wsl/docker-desktop/shared-sockets/host-services/backend.sock"); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable Shadowing: The WSL2 check uses if _, err = os.Stat(...) which shadows the outer err variable. While this works correctly, it might be clearer to use a new variable name or be explicit:

_, wslErr := os.Stat("/mnt/wsl/docker-desktop/shared-sockets/host-services/backend.sock")
if wslErr == nil {
    // Inside WSL2
    return DockerDesktopPaths{...}, nil
}
if !errors.Is(wslErr, os.ErrNotExist) {
    return DockerDesktopPaths{}, wslErr
}

This makes it clearer that we're checking a different filesystem operation.

@krissetto krissetto merged commit 4ab6436 into docker:main Jan 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants