Skip to content

Commit 1f58a53

Browse files
authored
Merge pull request containerd#8048 from profnandaa/docs/windows-setup
docs: add step to include binaries in the $env:Path
2 parents f5ed7b8 + 9ef94fe commit 1f58a53

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

docs/getting-started.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ To install containerd and its dependencies from the source, see [`BUILDING.md`](
110110
From a PowerShell session run the following commands:
111111

112112
```PowerShell
113+
# If containerd previously installed run:
114+
Stop-Service containerd
115+
113116
# Download and extract desired containerd Windows binaries
114-
$Version="1.6.4"
117+
$Version="1.7.13" # update to your preferred version
115118
curl.exe -L https://github.com/containerd/containerd/releases/download/v$Version/containerd-$Version-windows-amd64.tar.gz -o containerd-windows-amd64.tar.gz
116119
tar.exe xvf .\containerd-windows-amd64.tar.gz
117120
@@ -120,16 +123,41 @@ Copy-Item -Path ".\bin" -Destination "$Env:ProgramFiles\containerd" -Recurse -Co
120123
cd $Env:ProgramFiles\containerd\
121124
.\containerd.exe config default | Out-File config.toml -Encoding ascii
122125
126+
# Copy
127+
Copy-Item -Path .\bin\* -Destination (New-Item -Type Directory $Env:ProgramFiles\containerd -Force) -Recurse -Force
128+
129+
# add the binaries (containerd.exe, ctr.exe) in $env:Path
130+
$Path = [Environment]::GetEnvironmentVariable("PATH", "Machine") + [IO.Path]::PathSeparator + "$Env:ProgramFiles\containerd"
131+
[Environment]::SetEnvironmentVariable( "Path", $Path, "Machine")
132+
# reload path, so you don't have to open a new PS terminal later if needed
133+
$Env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
134+
135+
# configure
136+
containerd.exe config default | Out-File $Env:ProgramFiles\containerd\config.toml -Encoding ascii
123137
# Review the configuration. Depending on setup you may want to adjust:
124138
# - the sandbox_image (Kubernetes pause image)
125139
# - cni bin_dir and conf_dir locations
126-
Get-Content config.toml
140+
Get-Content $Env:ProgramFiles\containerd\config.toml
127141
128142
# Register and start service
129-
.\containerd.exe --register-service
143+
containerd.exe --register-service
130144
Start-Service containerd
131145
```
132146

147+
> **Tip for Running `containerd` Service on Windows:**
148+
>
149+
> `containerd` logs are not persisted when we start it as a service
150+
using Windows Service Manager. [`nssm`](https://nssm.cc) can be used to
151+
configure logs to go into a cyclic buffer:
152+
> ```powershell
153+
> nssm.exe install containerd
154+
> nssm.exe set containerd AppStdout "\containerd.log"
155+
> nssm.exe set containerd AppStderr "\containerd.err.log"
156+
> nssm.exe start containerd
157+
> # to stop:
158+
> nssm.exe stop containerd
159+
> ```
160+
133161
## Interacting with containerd via CLI
134162
135163
There are several command line interface (CLI) projects for interacting with containerd:

0 commit comments

Comments
 (0)