Merge pull request #8048 from profnandaa/docs/windows-setup

docs: add step to include binaries in the $env:Path
This commit is contained in:
Akihiro Suda 2024-02-08 08:18:59 +00:00 committed by GitHub
commit 1f58a53a61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -110,8 +110,11 @@ To install containerd and its dependencies from the source, see [`BUILDING.md`](
From a PowerShell session run the following commands: From a PowerShell session run the following commands:
```PowerShell ```PowerShell
# If containerd previously installed run:
Stop-Service containerd
# Download and extract desired containerd Windows binaries # Download and extract desired containerd Windows binaries
$Version="1.6.4" $Version="1.7.13" # update to your preferred version
curl.exe -L https://github.com/containerd/containerd/releases/download/v$Version/containerd-$Version-windows-amd64.tar.gz -o containerd-windows-amd64.tar.gz curl.exe -L https://github.com/containerd/containerd/releases/download/v$Version/containerd-$Version-windows-amd64.tar.gz -o containerd-windows-amd64.tar.gz
tar.exe xvf .\containerd-windows-amd64.tar.gz tar.exe xvf .\containerd-windows-amd64.tar.gz
@ -120,16 +123,41 @@ Copy-Item -Path ".\bin" -Destination "$Env:ProgramFiles\containerd" -Recurse -Co
cd $Env:ProgramFiles\containerd\ cd $Env:ProgramFiles\containerd\
.\containerd.exe config default | Out-File config.toml -Encoding ascii .\containerd.exe config default | Out-File config.toml -Encoding ascii
# Copy
Copy-Item -Path .\bin\* -Destination (New-Item -Type Directory $Env:ProgramFiles\containerd -Force) -Recurse -Force
# add the binaries (containerd.exe, ctr.exe) in $env:Path
$Path = [Environment]::GetEnvironmentVariable("PATH", "Machine") + [IO.Path]::PathSeparator + "$Env:ProgramFiles\containerd"
[Environment]::SetEnvironmentVariable( "Path", $Path, "Machine")
# reload path, so you don't have to open a new PS terminal later if needed
$Env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# configure
containerd.exe config default | Out-File $Env:ProgramFiles\containerd\config.toml -Encoding ascii
# Review the configuration. Depending on setup you may want to adjust: # Review the configuration. Depending on setup you may want to adjust:
# - the sandbox_image (Kubernetes pause image) # - the sandbox_image (Kubernetes pause image)
# - cni bin_dir and conf_dir locations # - cni bin_dir and conf_dir locations
Get-Content config.toml Get-Content $Env:ProgramFiles\containerd\config.toml
# Register and start service # Register and start service
.\containerd.exe --register-service containerd.exe --register-service
Start-Service containerd Start-Service containerd
``` ```
> **Tip for Running `containerd` Service on Windows:**
>
> `containerd` logs are not persisted when we start it as a service
using Windows Service Manager. [`nssm`](https://nssm.cc) can be used to
configure logs to go into a cyclic buffer:
> ```powershell
> nssm.exe install containerd
> nssm.exe set containerd AppStdout "\containerd.log"
> nssm.exe set containerd AppStderr "\containerd.err.log"
> nssm.exe start containerd
> # to stop:
> nssm.exe stop containerd
> ```
## Interacting with containerd via CLI ## Interacting with containerd via CLI
There are several command line interface (CLI) projects for interacting with containerd: There are several command line interface (CLI) projects for interacting with containerd: