Skip to main content
KBY Technologies Logo

Install containerd on Autopilot Laptops Without Rebooting Mid-Provisioning

Install containerd on Windows laptops provisioned by Autopilot. Split the installer into two Win32 apps so Intune plans the restart, not the script.

KBY Technologies12 min readTier L115 min
Install containerd on Autopilot Laptops Without Rebooting Mid-Provisioning

Advertising disclosure: this article includes partner links. KBY may earn a commission if you sign up or buy through one, at no extra cost to you. How we make money.

Underlined words are defined in the KBY Lexicon. Tap or click one to see what it means.

Microsoft’s installer for Windows restarts the laptop by itself when it has to turn on Windows features. It then registers a scheduled task that runs the script again at the next sign-in. On an Autopilot laptop that restart can land inside the Enrollment Status Page (ESP). Microsoft lists reboots packaged inside an app as a cause of ESP hangs and failed deployments.

The fix is to split the work in two. One Win32 app enables the Containers and Hyper-V features with no restart and reports that a restart is needed. A second Win32 app, which depends on the first, runs the installer with -NoRestart and pinned versions. Intune then owns the restart, which is what Microsoft recommends, and the installer never reboots anything.

This suits Windows 11 Pro or Enterprise laptops that a developer group uses to build and test containers. Microsoft’s container quickstart documents Desktop for Windows 10 and 11, and shows the containerd script under its heading. The script does have a client branch. Treat containerd on laptops as a developer workstation setup, and agree your support position before the pilot ends.

#How it usually goes when the installer meets Autopilot

The manual route in Microsoft’s quickstart is two commands: download install-containerd-runtime.ps1 from the Windows-Containers repository, then run it. The script installs containerd, nerdctl and the Windows container networking plug-ins. It also turns on the container-related operating system features.

On a laptop the script behaves differently, because it detects a client edition. It then assumes Hyper-V containers and enables both the Containers and Hyper-V features by default. If either needs a restart, the script registers a task named ContainerBootstrap to run at the next logon, then calls Restart-Computer. The task starts PowerShell with -NoExit, so it leaves an interactive window open, and Intune does not support interactive app installs.

Two more behaviours matter for a fleet. Unless you pass versions, the script asks api.github.com for the latest releases of containerd, nerdctl and the Windows container networking plug-ins. Two laptops provisioned a week apart can therefore get different builds. It also downloads at install time, so the laptop needs that access while it is still provisioning.

Wrap that script in a Win32 app with default settings and the failure is easy to picture. The ESP is tracking the app, the script enables the features, and the laptop restarts mid-install. A restart during device setup also means the user must enter their credentials again before account setup. If the app never reports back, the ESP waits until its time-out, which defaults to 60 minutes.

#A better way: two apps and one planned restart

The flow below keeps every restart inside Intune’s control. The features app does only what needs a restart, and the containerd app starts only once that restart has happened.

Loading diagram...

Win32 apps give you the pieces for this. A return code can be marked as a hard reboot, which does not allow the next Win32 app to install without a restart. A dependency stops the second app from being attempted until the first is in place. If a dependency is pending a restart, the user sees the message that one or more dependent apps are pending a device reboot.

Decide next whether either app may hold up the desktop. When the ESP blocks on selected apps in user-driven mode, Microsoft says a Win32 app outside that list installs after the ESP completes. Keeping both apps off the list gets the laptop to the desktop sooner, and the restart arrives as a notification.

If containerd must be ready at first sign-in, select the containerd app instead. Its dependency installs first, so expect a restart in device setup and a second credential prompt. Pilot that sequence before you trust it.

#Setting up the two Win32 apps

Start with the package, then build the features app, then the containerd app that depends on it. Work on one pilot laptop and one test group until the checks in the validation section pass.

  1. On a build machine, download install-containerd-runtime.ps1 from Microsoft’s Windows-Containers repository. Read it, because Microsoft supplies it as sample code provided as is. Record its hash with Get-FileHash .\install-containerd-runtime.ps1 -Algorithm SHA256 so a later change is visible.
  2. Choose containerd, nerdctl and Windows container networking releases and test them. The script builds the file names from the versions you pass, such as containerd-<version>-windows-amd64.tar.gz, so pass the number without a leading v.
  3. Create the features app with the PowerShell script installer type and upload the script below. Set the install behaviour to System. Under return codes, add 3010 as a hard reboot, and set device restart behaviour to App install may force a device restart. Hard reboot then notifies the user that a restart will be triggered in 120 minutes.
  4. Add the detection script below to the features app as a custom detection script. The app counts as installed when the script exits 0 and writes to STDOUT.
  5. Create the containerd app with the installer and the pinned versions. In the Dependencies step, add the features app with Automatically install set to Yes. Use a command-line installer so the version arguments reach the script.
  6. Give the containerd app the service detection script below, and set device restart behaviour to Determine behavior based on return codes.
  7. Write the uninstall command for the containerd app as a wrapper script in the package, because Intune does not expand environment variables in the uninstall command field.
  8. Assign both apps as required to the pilot group only, so that both report their status, and leave them off the ESP blocking list.

Following along? Tap a step’s number to tick it off.

The features app runs this script. It stops on any error, enables each feature without a restart, and exits 3010 only when Windows reports that a restart is needed.

1$ErrorActionPreference = 'Stop'
2$restartNeeded = $false
3foreach ($name in 'Containers', 'Microsoft-Hyper-V') {
4    $result = Enable-WindowsOptionalFeature -Online -FeatureName $name -All -NoRestart
5    if ($result.RestartNeeded) { $restartNeeded = $true }
6}
7if ($restartNeeded) { exit 3010 }
8exit 0

The detection script for the features app reads the state of both features, so a half-finished enablement is not counted as installed.

1$names = 'Containers', 'Microsoft-Hyper-V'
2foreach ($name in $names) {
3    if ((Get-WindowsOptionalFeature -Online -FeatureName $name).State -ne 'Enabled') { exit 1 }
4}
5Write-Output 'Containers and Hyper-V enabled'
6exit 0

The containerd app uses a command line that starts 64-bit PowerShell. Calling powershell.exe directly from the install command field starts a 32-bit instance, so the command uses the Sysnative path instead. Replace each version placeholder with the release you tested.

1%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File .\install-containerd-runtime.ps1 -ContainerDVersion <version> -NerdCTLVersion <version> -WinCNIVersion <version> -NoRestart

This detection script is what tells Intune the truth. Under -File, PowerShell exits 0 after a successful run, and an exit command sets any other code. Microsoft’s installer wraps its work in a try and catch block that only writes the error. A failed install may therefore finish with exit code 0, so the service check decides.

1if (Get-Service -Name containerd -ErrorAction SilentlyContinue) {
2    Write-Output 'containerd service present'
3    exit 0
4}
5exit 1

Windows Autopilot device preparation does not use the ESP, and Microsoft notes that it supports mixing line-of-business and Win32 apps, which the ESP does not. If you provision this group with it, repeat the pilot there before assuming the restart behaves the same. The device preparation setup guide covers the profile side.

A developer working on a laptop, typing code, showcasing programming and technology skills.
Photo by olia danilevich on Pexels

#Who can run it and what it may change

Assign the apps to a named developer group, never to all devices. Hyper-V cannot be installed on Windows 10 or 11 Home. It also needs a 64-bit processor with Second Level Address Translation and at least 4 GB of memory. Add a requirement rule so that an unsuitable laptop never receives the features app.

Enabling Hyper-V changes how other virtualisation software behaves. Products such as VMware Workstation and VirtualBox can fail to start virtual machines, or run unreliably, while the Hyper-V hypervisor is running. Ask the developer group which tools they use before the pilot, not after it.

Keep the installer unchanged apart from the arguments. Do not pass -TransparentNetwork in the first pilot, because that option creates a network bound to the laptop’s adapter. Leave -Force off too, since it forces an immediate restart. Own the package like any other software: a named person, a recorded hash and a review before each version change.

Finally, agree who may change the ESP profile for this group. Adding the containerd app to the blocking list puts a download from GitHub inside the provisioning time-out. Review the ESP blocking-apps configuration before anyone makes that change.

#Check it worked on one pilot laptop

Provision the pilot laptop with Autopilot, sign in, and let both apps install. Run the checks below from an elevated PowerShell session once the planned restart has happened. Every one of them only reads state.

  1. Confirm that the ESP finished inside its time-out and that nobody was asked for credentials twice. Compare the time with a laptop provisioned without these apps.
  2. Run Get-WindowsOptionalFeature -Online -FeatureName Containers and the same command with Microsoft-Hyper-V. Both should show State Enabled.
  3. Run Get-Service -Name containerd. The status should be Running.
  4. Run nerdctl version. It should complete without an error, which is the same test the installer uses to wait for the daemon.
  5. Run nerdctl images -a. An empty list is a pass, because the list shows the images that are present on the machine.
  6. Run Get-ScheduledTask -TaskName ContainerBootstrap. It should return nothing or report that no such task exists. That shows the installer never took its own restart path.

Then prove the safety switch on a spare pilot laptop that has never had these apps. Run .\install-containerd-runtime.ps1 -NoRestart from an elevated session. The script should enable the features, print that a reboot is required, and stop. The laptop must not restart, and the ContainerBootstrap task must not exist afterwards.

#Where it goes wrong

The most common failure is the containerd app running before the restart. The installer prints that a reboot is required and stops without setting an error code. Detection then fails and Intune retries up to three times, five minutes apart. Check the dependency and the hard reboot code on the features app.

A second failure is a hang in the ESP. A common cause is a restart packaged inside an app, for example because someone removed -NoRestart from the command. Restore the command and keep restart behaviour in the Intune settings, where Microsoft recommends it.

Third, an unpinned version drifts. If the pilot’s nerdctl version output differs from the last laptop’s, the version arguments were lost. Fourth, a laptop on a restricted network cannot reach GitHub, and the download fails. A proxy log on the pilot shows which hosts the installer used, and those are the ones to allow.

Last, check the Hyper-V feature name. The installer asks for a feature called Hyper-V, while Microsoft’s Hyper-V page uses Microsoft-Hyper-V. The pilot checks above use the documented name, so they hold either way. Still read the installer’s output for an error or an odd message at that step, and stop if you see one.

Industrial worker managing inventory in a warehouse with a clipboard and checklist.
Photo by Daniel Andraski on Pexels

#Rollback if the pilot fails

Take the apps off the group first, so no new laptop receives them. Then decide whether the laptop is worth keeping. A reset and a fresh Autopilot run is the cleanest way back, because it restores the laptop to a state you have already proven.

To remove containerd without a reset, use the same steps as the installer’s own removal routine, in Windows PowerShell on a pilot laptop only. Stop any running containers first. Copy config.toml from the containerd folder, because the removal deletes it. Record the machine Path value too, because the installer adds the containerd and nerdctl folders to it and the removal does not undo that. Images and container data stay on disk.

1Stop-Service -Name containerd
2(Get-WmiObject -Class Win32_Service -Filter "Name='containerd'").delete()
3Remove-Item -Recurse -Force "$Env:ProgramFiles\containerd"
4Remove-Item -Recurse -Force "$Env:ProgramFiles\nerdctl"

Leave the Containers and Hyper-V features on unless the laptop needs another virtualisation tool. Turn them off from the Windows features dialog that Microsoft’s Hyper-V page describes, and restart when prompted.

#What to track after roll-out

Count laptops where both apps report installed, and compare that with the number assigned. Track the time from first sign-in to a running containerd service on each new laptop. Watch the ESP time for the developer group against the rest of the fleet. A rise points to a restart or a download inside provisioning.

Each month, sample the nerdctl version output on a few laptops from the group. Any laptop that differs from the pinned versions needs a look. Record the counts before and after, and only then widen the group.

#Before you go live

  • The script hash is recorded and the script has been read by a named reviewer.
  • Versions of containerd, nerdctl and the networking plug-ins are pinned and tested.
  • Both apps have detection scripts, and the dependency is set to install automatically.
  • The 3010 return code is a hard reboot and the restart behaviour matches the pilot.
  • The ESP blocking list does not include the containerd app.
  • The assignment is a named developer group on Windows 11 Pro or Enterprise.
  • The pilot proved the six checks and the deliberate failure test.
  • A removal wrapper and a reset plan are ready before the second group starts.

About this page

Credited to

Dates

Published

Sources

This page lists no external sources.

Corrections

No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.

Found this useful? Follow KBY for more like it.

Reader Interaction

Comments

Add a thoughtful note on Install containerd on Autopilot Laptops Without Rebooting Mid-Provisioning. Comments are checked for spam and held for moderation before appearing.

Loading comments...

More from KBY that goes with this article.

Discover more

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

Operate smarter, with fewer recurring tickets.

Receive new operational playbooks, incident-prevention guidance, automation scripts and recovery runbooks.