Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows %PATH% shows as linux path, not windows path? #2485

Open
brwilkinson opened this issue Sep 9, 2023 · 5 comments
Open

Windows %PATH% shows as linux path, not windows path? #2485

brwilkinson opened this issue Sep 9, 2023 · 5 comments
Labels
bug Something isn't working platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2)

Comments

@brwilkinson
Copy link

Description

I am wondering what is the source of this difference below?

I see a related discussion:

containerd --version
containerd github.com/containerd/containerd v1.7.5 fe457eb99ac0e27b3ce638175ef8e68a7d2bc373
nerdctl version
time="2023-09-09T13:18:19-07:00" level=warning msg="unable to determine buildctl version: exec: \"buildctl\": executable file not found in %PATH%"
time="2023-09-09T13:18:19-07:00" level=warning msg="unable to determine runc version: exec: \"runc\": executable file not found in %PATH%"
Client:
 Version:       v1.5.0
 OS/Arch:       windows/amd64
 Git commit:    b33a58f288bc42351404a016e694190b897cd252
 buildctl:
  Version:

Server:
 containerd:
  Version:      v1.7.5
  GitCommit:    fe457eb99ac0e27b3ce638175ef8e68a7d2bc373
 runc:
  Version:
cni version 0.3.0

Steps to reproduce the issue

nerdctl run --rm mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022 cmd /c "echo %path%"
> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
docker run --rm mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022 cmd /c "echo %path%"
> C:\Windows\system32;C:\Windows;;C:\Program Files\PowerShell;

Describe the results you received and expected

Docker shows the correct windows path, however nerdctl shows the linux path ?

What version of nerdctl are you using?

Version: v1.7.5

Are you using a variant of nerdctl? (e.g., Rancher Desktop)

None

Host information

nerdctl info
Client:
Namespace: default
Debug Mode: false

Server:
Server Version: v1.7.5
Storage Driver: windows
Logging Driver: json-file
Cgroup Driver:
Cgroup Version:
Plugins:
Log: fluentd journald json-file syslog
Storage: windows-lcow windows
Security Options:
Kernel Version:
Operating System:
OSType: windows
Architecture:
CPUs: 0
Total Memory: 0B
Name: BRW-SB3
ID: fe8b756d-59de-46e4-bdc6-e56d63c158c5

@brwilkinson brwilkinson added the kind/unconfirmed-bug-claim Unconfirmed bug claim label Sep 9, 2023
@brwilkinson
Copy link
Author

not sure if this is helpful, however ...

docker inspect 570f5c4f678f
[
    {
        "Id": "sha256:570f5c4f678f5dfb03807894dcc696382a5ac9db713705bb436c903b8574601a",
        "RepoTags": [
            "mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022"
        ],
        "RepoDigests": [
            "mcr.microsoft.com/powershell@sha256:5e0222bb80f4cc5b63fc0eb51ca16001a141575d7b2253e32ed5ffb029c536d3"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2023-07-13T18:32:08.5185745Z",
        "Container": "ce5af146daa5d4e567070277fee5a74b5e17e9025b144b5e268e72a9449f0117",
        "ContainerConfig": {
            "Hostname": "ce5af146daa5",
            "Domainname": "",
            "User": "ContainerUser",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "ProgramFiles=C:\\Program Files",
                "PSModuleAnalysisCachePath=C:\\Users\\Public\\AppData\\Local\\Microsoft\\Windows\\PowerShell\\docker\\ModuleAnalysisCache",
                "PSCORE=\\PowerShell\\pwsh.exe",
                "WindowsPATH=C:\\Windows\\system32;C:\\Windows",
                "POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-NanoServer-ltsc2022",
                "POWERSHELL_TELEMETRY_OPTOUT=0"
            ],
            "Cmd": [
                "cmd",
                "/S",
                "/C",
                "#(nop) ",
                "CMD [\"pwsh.exe\"]"
            ],
            "Image": "sha256:2f9ca742140ef8085256cda281477c61dfdc7ac0982ea7639ed5dd19795214b4",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "20.10.15+azure",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "ContainerUser",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "ProgramFiles=C:\\Program Files",
                "PSModuleAnalysisCachePath=C:\\Users\\Public\\AppData\\Local\\Microsoft\\Windows\\PowerShell\\docker\\ModuleAnalysisCache",
                "PSCORE=\\PowerShell\\pwsh.exe",
                "WindowsPATH=C:\\Windows\\system32;C:\\Windows",
                "POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-NanoServer-ltsc2022",
                "POWERSHELL_TELEMETRY_OPTOUT=0"
            ],
            "Cmd": [
                "pwsh.exe"
            ],
            "Image": "sha256:2f9ca742140ef8085256cda281477c61dfdc7ac0982ea7639ed5dd19795214b4",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "windows",
        "OsVersion": "10.0.20348.1850",
        "Size": 561631538,
        "VirtualSize": 561631538,
        "GraphDriver": {
            "Data": {
                "dir": "C:\\ProgramData\\Docker\\windowsfilter\\89d9b262e9234514035e027490e48fffda67baad9138f86fe894890c2d804ab4"
            },
            "Name": "windowsfilter"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:765c01b50936296499b458db80437b4f0c7d0216038c7d759d8741e7b509817a",
                "sha256:fa9662a9b6052f44b955a33fc3b88f98eed57c5a32f2326aea76e31e0c1b8a00",
                "sha256:17fecc8860e0ad25fc46408dd70f83e7cd9ac2d2b38067e1218115e90ce92d84",
                "sha256:146c63fb0f78c24787c2c43d00d031b54ed8c1b4196a409ccc7d5fd8c3431dc4",
                "sha256:97e9e225a31aff1afa9b184d8314859f0d008994d0978de385add7ce7a6e43cb",
                "sha256:b228a9de938a0c9026a7a19782c006062784754133c30a4edbedd25199a6362c",
                "sha256:f1909cad41aea8bf0571b57aa08f54e8e32fba1b36bdf9f67cacf1c260140636",
                "sha256:3bc4e6efd83306e643f92187c511bbb63b0de391c24b3dd65312d12291cc7bbe",
                "sha256:459d86538d500e284cf08721906c175dd59e63169c2c09afd1a191d59db7d6a5"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

@brwilkinson
Copy link
Author

nerdctl inspect 5e0222bb80f4
[
    {
        "Id": "sha256:570f5c4f678f5dfb03807894dcc696382a5ac9db713705bb436c903b8574601a",
        "RepoTags": [
            "mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022"
        ],
        "RepoDigests": [
            "mcr.microsoft.com/powershell@sha256:5e0222bb80f4cc5b63fc0eb51ca16001a141575d7b2253e32ed5ffb029c536d3"
        ],
        "Comment": "",
        "Created": "2023-07-13T18:32:08.5185745Z",
        "Author": "",
        "Config": {
            "User": "ContainerUser",
            "AttachStdin": false,
            "Env": [
                "ProgramFiles=C:\\Program Files",
                "PSModuleAnalysisCachePath=C:\\Users\\Public\\AppData\\Local\\Microsoft\\Windows\\PowerShell\\docker\\ModuleAnalysisCache",
                "PSCORE=\\PowerShell\\pwsh.exe",
                "WindowsPATH=C:\\Windows\\system32;C:\\Windows",
                "POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-NanoServer-ltsc2022",
                "POWERSHELL_TELEMETRY_OPTOUT=0"
            ],
            "Cmd": [
                "pwsh.exe"
            ]
        },
        "Architecture": "amd64",
        "Os": "windows",
        "Size": 1186816416,
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:765c01b50936296499b458db80437b4f0c7d0216038c7d759d8741e7b509817a",
                "sha256:fa9662a9b6052f44b955a33fc3b88f98eed57c5a32f2326aea76e31e0c1b8a00",
                "sha256:17fecc8860e0ad25fc46408dd70f83e7cd9ac2d2b38067e1218115e90ce92d84",
                "sha256:146c63fb0f78c24787c2c43d00d031b54ed8c1b4196a409ccc7d5fd8c3431dc4",
                "sha256:97e9e225a31aff1afa9b184d8314859f0d008994d0978de385add7ce7a6e43cb",
                "sha256:b228a9de938a0c9026a7a19782c006062784754133c30a4edbedd25199a6362c",
                "sha256:f1909cad41aea8bf0571b57aa08f54e8e32fba1b36bdf9f67cacf1c260140636",
                "sha256:3bc4e6efd83306e643f92187c511bbb63b0de391c24b3dd65312d12291cc7bbe",
                "sha256:459d86538d500e284cf08721906c175dd59e63169c2c09afd1a191d59db7d6a5"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

@AkihiroSuda AkihiroSuda added the platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2) label Sep 10, 2023
@iankingori
Copy link

iankingori commented Sep 11, 2023

This bug is caused by a containerd bug here which only has default for unix env:

func WithDefaultPathEnv(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
        s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, defaultUnixEnv)
	return nil
}

We are using the function here to set environment variables and end up overwriting the default windows path. I believe Windows Containers have a default path already configured at bootup so solution here might be to have WithDefaultPathEnv function do nothing for Windows?

@CharityKathure
Copy link

CharityKathure commented Oct 11, 2023

Containerd issue resolved by this PR: containerd/containerd#9118.

cc @iankingori @brwilkinson

@iankingori
Copy link

The fix for this was backported into Containerd 1.7.11 and 1.6.26. I've confirmed the bug no longer repros on the latest release of nerdctl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2)
Projects
None yet
Development

No branches or pull requests

4 participants