Skip to content

fix(cli): support docker model logs from WSL2 with Docker Desktop#761

Merged
doringeman merged 1 commit intodocker:mainfrom
doringeman:cli-wsl2
Mar 18, 2026
Merged

fix(cli): support docker model logs from WSL2 with Docker Desktop#761
doringeman merged 1 commit intodocker:mainfrom
doringeman:cli-wsl2

Conversation

@doringeman
Copy link
Contributor

@doringeman doringeman commented Mar 17, 2026

Addresses the third issue reported in #750.

Enable docker model logs within WSL2 Docker Desktop integrated distro.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The new linux branch in the OS switch assumes WSL2 with Docker Desktop; consider detecting WSL explicitly (e.g., via WSL_DISTRO_NAME or checking wslvar availability) and either falling back or using a different path on native Linux to avoid misrouting logs on non-WSL Linux hosts.
  • You unconditionally enable Poll mode for all Linux platforms; it might be safer to tie this to the same WSL detection used for resolving the Windows home directory so native Linux tails continue using the default, more efficient behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `linux` branch in the OS switch assumes WSL2 with Docker Desktop; consider detecting WSL explicitly (e.g., via `WSL_DISTRO_NAME` or checking `wslvar` availability) and either falling back or using a different path on native Linux to avoid misrouting logs on non-WSL Linux hosts.
- You unconditionally enable `Poll` mode for all Linux platforms; it might be safer to tie this to the same WSL detection used for resolving the Windows home directory so native Linux tails continue using the default, more efficient behavior.

## Individual Comments

### Comment 1
<location path="cmd/cli/commands/logs.go" line_range="78-85" />
<code_context>
 			case "windows":
 				serviceLogPath = filepath.Join(homeDir, "AppData/Local/Docker/log/host/inference.log")
 				runtimeLogPath = filepath.Join(homeDir, "AppData/Local/Docker/log/host/inference-llama.cpp-server.log")
+			case "linux":
+				// When running inside WSL2 with Docker Desktop, the log files
+				// are on the Windows host filesystem mounted under /mnt/.
+				winHomeDir, wslErr := windowsHomeDirFromWSL(cmd.Context())
+				if wslErr != nil {
+					return fmt.Errorf("unable to determine Windows home directory from WSL2: %w", wslErr)
+				}
+				serviceLogPath = filepath.Join(winHomeDir, "AppData/Local/Docker/log/host/inference.log")
+				runtimeLogPath = filepath.Join(winHomeDir, "AppData/Local/Docker/log/host/inference-llama.cpp-server.log")
 			default:
</code_context>
<issue_to_address>
**issue (bug_risk):** Linux handling assumes WSL2 tools are present, which breaks on non-WSL Linux environments.

This branch treats all Linux environments as WSL2 with Docker Desktop and requires `wslvar`/`wslpath`. On native Linux, this will always fail, even though logs may be elsewhere or behavior should differ.

Please either:
- Detect WSL explicitly (e.g., via `WSL_INTEROP`, `/proc/version`, etc.) before calling `windowsHomeDirFromWSL`, or
- Provide a separate code path or clearer error for non-WSL Linux so native Linux users don’t hit a WSL-specific failure.

Currently this change effectively makes WSL tooling a requirement for all Linux users.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for docker model logs within a WSL2 environment by correctly locating log files on the Windows host filesystem. The implementation correctly uses wslvar and wslpath to resolve the path and enables polling for file changes, which is necessary for this setup. My review includes a suggestion to refactor the code that determines log file paths to reduce duplication between the Windows and Linux (WSL) cases, which will improve the code's maintainability.

Signed-off-by: Dorin Geman <dorin.geman@docker.com>
@doringeman doringeman merged commit 78a3092 into docker:main Mar 18, 2026
9 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.

2 participants