From 9ef94fe528baf9424ade37125fdbed6bc8dc6a8b Mon Sep 17 00:00:00 2001 From: Anthony Nandaa Date: Mon, 5 Feb 2024 11:39:56 +0300 Subject: [PATCH] fix(docs): fix cp and add step to include binaries in the $env:Path This commit adds an extra (optional) step for the Windows installation/set-up to include the containerd binaries in the $env:Path so that later executions especially for `ctr.exe` if needed, do not require to specify the full path. It also further fixes the previous steps to be absolute and also work with re-installations and upgrades. Signed-off-by: Anthony Nandaa --- docs/getting-started.md | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 2c390ca29..5ad5d730b 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -110,8 +110,11 @@ To install containerd and its dependencies from the source, see [`BUILDING.md`]( From a PowerShell session run the following commands: ```PowerShell +# If containerd previously installed run: +Stop-Service containerd + # 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 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\ .\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: # - the sandbox_image (Kubernetes pause image) # - cni bin_dir and conf_dir locations -Get-Content config.toml +Get-Content $Env:ProgramFiles\containerd\config.toml # Register and start service -.\containerd.exe --register-service +containerd.exe --register-service 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 There are several command line interface (CLI) projects for interacting with containerd: