Closed 4ampro closed 6 months ago
This error is typically caused by a faulty docker installation/file system (can be caused by many things - maybe the errors you had earlier). But... - it looks like the license error is gone. I usually use this mechanism https://freddysblog.com/2018/12/11/clean-up-after-yourself-docker-your-mom-isnt-here/ to cleanup my docker file system.
I just completely uninstalled then installed docker prior to running any of these scripts. 'Docker Services not running' message sometimes pops up no matter how may times I uninstall it or install it.
Strange.
Uninstalling docker might not cleanup a faulty file system.
what docker version are you running? (docker desktop, mirantis, docker engine?)
PS C:\WINDOWS\system32> docker version Client: Cloud integration: v1.0.35+desktop.11 Version: 25.0.3 API version: 1.44 Go version: go1.21.6 Git commit: 4debf41 Built: Tue Feb 6 21:13:02 2024 OS/Arch: windows/amd64 Context: default
Server: Docker Desktop 4.28.0 (139021) Engine: Version: 25.0.3 API version: 1.44 (minimum version 1.24) Go version: go1.21.6 Git commit: f417435 Built: Tue Feb 6 20:55:49 2024 OS/Arch: windows/amd64 Experimental: false
I think there is a later docker desktop version - I seem to remember a problem with one of the prior versions - maybe that is what you have. I personally use Docker Engine (using this script to install and update https://github.com/microsoft/nav-arm-templates/blob/master/InstallOrUpdateDockerEngine.ps1)
Gotcha but am I wrong to download 'docker' from the docker site?
Docker Desktop is fine - 4.27.x just had some errors, which should be fixed in 4.28.0 The cleanup tool works with both - you can try that if you like.
I was on 4.28.0.
Just ran your InstallOrUpdateDockerEngine script. Now running New-BCContainer.
Results in few minutes...
You should probably run the cleanup script to cleanup the file system
this? CleanupAfterDocker.ps1 If so, I'll stop my New-BCContainer, and run that one instead.
And btw, thanks for your help!
yes - that one repairs the windowsfilter file system
sweet.
running cleanupAfterDocker then New-BCContainer
Says I'm not running Windows Containers which would be a problem but the Docker Icon seems to indicate I can switch to Linux which would mean I am running Windows Containers?
PS C:\WINDOWS\system32> X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1
Checking Docker Service Settings...
Docker is not running Windows Containers
At X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1:29 char:5
+ throw "Docker is not running Windows Containers"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Docker is not running Windows Containers:String) [], RuntimeException
+ FullyQualifiedErrorId : Docker is not running Windows Containers
It seems I am running windows?
PS C:\WINDOWS\system32> X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1
Checking Docker Service Settings...
Docker is not running Windows Containers
At X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1:29 char:5
+ throw "Docker is not running Windows Containers"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Docker is not running Windows Containers:String) [], RuntimeException
+ FullyQualifiedErrorId : Docker is not running Windows Containers
PS C:\WINDOWS\system32> $dockerOsMode
windows
Docker returns lower case 'windows' and the script is looking for 'Windows' and seems it is case-sensitive.
$dockerInfo = (docker info)
$dockerOsMode = ($dockerInfo | Where-Object { $_.Trim().StartsWith('OSType: ') }).SubString(8)
if ($dockerOsMode -ne "Windows") {
throw "Docker is not running Windows Containers"
}
PS C:\WINDOWS\system32> X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1
Checking Docker Service Settings...
Docker is not running Windows Containers
At X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1:29 char:5
+ throw "Docker is not running Windows Containers"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Docker is not running Windows Containers:String) [], RuntimeException
+ FullyQualifiedErrorId : Docker is not running Windows Containers
PS C:\WINDOWS\system32> $dockerOsMode
windows
Edit:
PS C:\WINDOWS\system32> docker info
Client:
Version: 25.0.3
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1-desktop.4
Path: C:\Program Files\Docker\cli-plugins\docker-buildx.exe
compose: Docker Compose (Docker Inc.)
Version: v2.24.6-desktop.1
Path: C:\Program Files\Docker\cli-plugins\docker-compose.exe
debug: Get a shell into any image or container. (Docker Inc.)
Version: 0.0.24
Path: C:\Program Files\Docker\cli-plugins\docker-debug.exe
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.0
Path: C:\Program Files\Docker\cli-plugins\docker-dev.exe
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.22
Path: C:\Program Files\Docker\cli-plugins\docker-extension.exe
feedback: Provide feedback, right in your terminal! (Docker Inc.)
Version: v1.0.4
Path: C:\Program Files\Docker\cli-plugins\docker-feedback.exe
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.0.1
Path: C:\Program Files\Docker\cli-plugins\docker-init.exe
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: C:\Program Files\Docker\cli-plugins\docker-sbom.exe
scout: Docker Scout (Docker Inc.)
Version: v1.5.0
Path: C:\Program Files\Docker\cli-plugins\docker-scout.exe
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 25.0.3
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics internal l2bridge l2tunnel nat null overlay private transparent
Log: awslogs etwlogs fluentd gcplogs gelf json-file local splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 19045 (19041.1.amd64fre.vb_release.191206-1406)
Operating System: Microsoft Windows Version 22H2 (OS Build 19045.4170)
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 15.91GiB
Name: navDev
ID: 703db57e-f0cf-435d-93e4-6f5bca5679e2
Docker Root Dir: C:\ProgramData\Docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
PowerShell -ne operator is case insensitive. There does however seem to be a space in front of the Windows. The line should be
$dockerOsMode = ($dockerInfo | Where-Object { $_.Trim().StartsWith('OSType: ') }).Trim().SubString(8)
Which is updated here https://github.com/microsoft/nav-arm-templates/blob/master/CleanupAfterDocker.ps1 - but apparently not in the blogpost (or where you took the script from)
Freddy, thank you very much for helping me. I'm kind of a noob but doing as you recommend:
Which is updated here https://github.com/microsoft/nav-arm-templates/blob/master/CleanupAfterDocker.ps1 - but apparently not in the blogpost (or where you took the script from)
PS C:\WINDOWS\system32> X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1
$ErrorActionPreference : The term '$ErrorActionPreference' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1:1 char:1
+ $ErrorActionPreference = "Stop"
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ($ErrorActionPreference:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
I think you need to run
. "X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1"
But maybe there is an encoding BOM in the file - or maybe the file needs to be unblocked by windows explorer
I have updated the script in the block post as well
So, I'll run 'CleanUpAfterDocker' from here: https://freddysblog.com/2018/12/11/clean-up-after-yourself-docker-your-mom-isnt-here/
PS C:\WINDOWS\system32> X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1
$ErrorActionPreference : The term '$ErrorActionPreference' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1:1 char:1
+ $ErrorActionPreference = "Stop"
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ($ErrorActionPreference:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
$ErrorActionPreference = "Stop"
$WarningActionPreference = "Stop"
# Specify which images to download
$ImagesToDownload = @()
$bcContainerHelperFolder = "C:\ProgramData\BcContainerHelper"
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if (!($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) {
throw "This script must run with administrator privileges"
}
Write-Host "Checking Docker Service Settings..."
$dockerService = (Get-Service docker -ErrorAction Ignore)
if (!($dockerService)) {
throw "Docker Service not found / Docker is not installed"
}
if ($dockerService.Status -ne "Running") {
throw "Docker Service is $($dockerService.Status) (Needs to be running)"
}
$dockerInfo = (docker info)
$dockerOsMode = ($dockerInfo | Where-Object { $_.Trim().StartsWith('OSType: ') }).Trim().SubString(8)
if ($dockerOsMode -ne "Windows") {
throw "Docker is not running Windows Containers"
}
$dockerRootDir = ($dockerInfo | Where-Object { $_.Trim().StartsWith('Docker Root Dir: ') }).Trim().SubString(17)
if (!(Test-Path $dockerRootDir -PathType Container)) {
throw "Folder $dockerRootDir does not exist"
}
Write-Host -Foregroundcolor Red "This function will remove all containers, remove all images and clear the folder $dockerRootDir"
Write-Host -Foregroundcolor Red "The function will also clear the contents of $bcContainerHelperFolder."
Write-Host -Foregroundcolor Red "Are you absolutely sure you want to do this? (This cannot be undone)"
Write-Host -ForegroundColor Red "Type Yes to continue:" -NoNewline
if ((Read-Host) -ne "Yes") {
throw "Mission aborted"
}
Write-Host "Running Docker System Prune"
docker system prune -f
Write-Host "Removing all containers (forced)"
docker ps -a -q | % { docker rm $_ -f 2> NULL }
Write-Host "Stopping Docker Service"
stop-service docker
Write-Host "Downloading Docker-Ci-Zap"
$dockerCiZapExe = Join-Path $Env:TEMP "docker-ci-zap.exe"
Remove-Item $dockerCiZapExe -Force -ErrorAction Ignore
(New-Object System.Net.WebClient).DownloadFile("https://github.com/moby/docker-ci-zap/raw/master/docker-ci-zap.exe", $dockerCiZapExe)
Unblock-File -Path $dockerCiZapExe
Write-Host "Running Docker-Ci-Zap on $dockerRootDir"
Write-Host -ForegroundColor Yellow "Note: If this fails, please restart your computer and run this script again"
& $dockerCiZapExe -folder $dockerRootDir
Write-Host "Removing Docker-Ci-Zap"
Remove-Item $dockerCiZapExe
Write-Host "Starting Docker Service"
Start-Service docker
if (Test-Path $bcContainerHelperFolder -PathType Container) {
Write-Host "Cleaning up $bcContainerHelperFolder"
Get-ChildItem $bcContainerHelperFolder -Force | ForEach-Object {
Remove-Item $_.FullName -Recurse -force
}
}
if ($ImagesToDownload) {
Write-Host -ForegroundColor Green "Done cleaning up, pulling images for $os"
$os = "ltsc2016"
if ((Get-CimInstance win32_operatingsystem).BuildNumber -ge 17763) { $os = "ltsc2019" }
# Download images needed
$imagesToDownload | ForEach-Object {
if ($_.EndsWith('-ltsc2016') -or $_.EndsWith('-1709') -or $_.EndsWith('-1803') -or $_.EndsWith('-ltsc2019') -or
$_.EndsWith(':ltsc2016') -or $_.EndsWith(':1709') -or $_.EndsWith(':1803') -or $_.EndsWith(':ltsc2019')) {
$imageName = $_
} elseif ($_.Contains(':')) {
$imageName = "$($_)-$os"
} else {
$imageName = "$($_):$os"
}
Write-Host "Pulling $imageName"
docker pull $imageName
}
}
If you are saying that you cannot run these lines in PowerShell:
$ErrorActionPreference = "Stop"
$WarningActionPreference = "Stop"
Then I guess you cannot run anything - I don't know what went wrong there - sorry. These are setting the preference of what to do if something fails or gives a warning,
$WarningActionPreference is type 'string' so "Stop" is valid. $ErrorActionPreference is type 'ActionPreference' and setting its value to "Stop" seems to be the issue? I could be completely on the wrong path - like I said, I'm a noob.
So, I restarted my machine and it seems it may have allowed me to continue past the $ErrorActionPreference is not recognized
issue. I'm going to type Yes to continue:
PS C:\WINDOWS\system32> X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1
$ErrorActionPreference : The term '$ErrorActionPreference' is not recognized
as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is
correct and try again.
At X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1:1 char:1
+ $ErrorActionPreference = "Stop"
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ($ErrorActionPreference:String)
[], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Checking Docker Service Settings...
This function will remove all containers, remove all images and clear the folder
C:\ProgramData\Docker
The function will also clear the contents of C:\ProgramData\BcContainerHelper.
Are you absolutely sure you want to do this? (This cannot be undone)
Type Yes to continue:Yes
Running Docker System Prune
Deleted Networks:
Default Switch
Total reclaimed space: 0B
Removing all containers (forced)
Stopping Docker Service
WARNING: Waiting for service 'Docker Engine (docker)' to stop...
WARNING: Waiting for service 'Docker Engine (docker)' to stop...
Downloading Docker-Ci-Zap
Running Docker-Ci-Zap on C:\ProgramData\Docker
Note: If this fails, please restart your computer and run this script again
INFO: Zapped successfully
Removing Docker-Ci-Zap
Starting Docker Service
Start-Service : Failed to start service 'Docker Engine (docker)'.
At X:\Documents\Nav stuff\Docker\bc02\Freddy CleanupAfterDocker.ps1:66 char:1
+ Start-Service docker
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service], ServiceCommandException
+ FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands.StartServiceCommand
Cleaning up C:\ProgramData\BcContainerHelper
PS C:\WINDOWS\system32>
What version of PowerShell are you running here?
$PSVersionTable tells you
PS C:\WINDOWS\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.4170
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.4170
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
ISE (x86) or ISE?
sorry i'm a dummy: there is no help | about, so the window text is 'Administrator: Windows PowerShell ISE'.
Presumably ISE?
Yes.
So,...
$ErrorActionPreference = "Stop"
is used all over.
the variable is an enum - and it automatically converts strings to that - the fact that this isn't working doesn't give me much confidence in anything working.
Sorry - you might need to find somebody who knows how to troubleshoot this or reinstall the machine.
Understandable.
One quirky thing: $ErrorActionPreference = "Stop"
runs by itself with no issues.
When it runs in the script you provided, it fails.
and if you copy/paste the script into a new tab without saving it and using F5 to run it - it still fails?
I have seen a million different issues and problems with PowerShell - but this one is new.
What does the command Get-ExecutionPolicy return? Is the .ps1 file blocked in Windows Explorer?
I just uninstalled then installed the latest of both docker and pse. I've been using Docker and Pse for the last few years with minor issues. This came from out of nowhere from what it seems but the ONLY use of these two apps is for New-BCContainer and BC-related stuff like updating licenses when they get renewed and some ancillary things like listing containers, but nothing major.
I reinstalled Docker (as admin) from the file on its web site.
I reinstalled PSE from command line (as admin): winget install --id Microsoft.Powershell --source winget
Both are running as admin.
and if you copy/paste the script into a new tab without saving it and using F5 to run it - it still fails?
$ErrorActionPreference : The term '$ErrorActionPreference' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + $ErrorActionPreference = "Stop" + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: ($ErrorActionPreference:String) [], Comma ndNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Checking Docker Service Settings... This function will remove all containers, remove all images and clear the folder C:\Progra mData\Docker The function will also clear the contents of C:\ProgramData\BcContainerHelper. Are you absolutely sure you want to do this? (This cannot be undone) Type Yes to continue:Yes Running Docker System Prune Deleted Networks: Default Switch
Total reclaimed space: 0B Removing all containers (forced) Stopping Docker Service WARNING: Waiting for service 'Docker Engine (docker)' to stop... WARNING: Waiting for service 'Docker Engine (docker)' to stop... Downloading Docker-Ci-Zap Running Docker-Ci-Zap on C:\ProgramData\Docker Note: If this fails, please restart your computer and run this script again INFO: Zapped successfully Removing Docker-Ci-Zap Starting Docker Service Start-Service : Failed to start service 'Docker Engine (docker)'. At line:66 char:1
+ CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:Servic
eController) [Start-Service], ServiceCommandException
+ FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands.StartServ
iceCommand
Cleaning up C:\ProgramData\BcContainerHelper
> What does the command Get-ExecutionPolicy return?
PS C:\WINDOWS\system32> Get-ExecutionPolicy RemoteSigned
> Is the .ps1 file blocked in Windows Explorer?
No.
I have seen a million different issues and problems with PowerShell - but this one is new.
How do I move this up the ladder if we cannot figure it out between us? Wiping my machine is not an option really.
Anyhow, I downloaded my license again, specifying v21 and I'm back to basically another 'file not found' issue. Something is just not right and the non-cumulative error reporting that trickles out errors until the real cause is discovered is driving me to drink the Heinekens.
I've uninstalled, reinstalled, downloaded the latest, stood on one leg when the Worm Moon is full and all that jazz - even on a Monday. After working fine for years. Go figure?
DockerDo : re-exec error: exit status 1: output: hcsshim::ImportLayer failed in Win32: The system cannot find the path specified. (0x3)
ExitCode: 1
Commandline: docker build --isolation=hyperv --memory 8G --no-cache --tag y:sandbox-23.5.16502.17828-us-mt c:\bcartifacts.cache\cfuzy3jy.3cd
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\6.0.11\ContainerHandling\New-NavImage.ps1:711 char:27
+ ... if (!(DockerDo -command build -parameters @("--isolation=$isola ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,DockerDo
One thing I just saw... - remove the -accept_outdated line and try again.
New-BCContainer `
-accept_eula `
-containerName $ContainerName `
-artifactUrl $artifactUrl `
-alwayspull `
-auth NavUserPassword `
-updateHosts `
-Credential $Credential `
-includeTestToolkit `
-isolation hyperv
You specified the value as it was a boolean - it isn't - it is a switch, meaning that the boolean value was presumed to be the value for imagename and subsequently, it tries to create an image. Without the line, it might work better.
You did it. You crazy son of a bitch, you did it. That's some kung fu voodoo for sure!
Thanks for sticking with me all day. If I ever catch you at a conference, I you some cold beer for sure.
Really man, thank you so much for the 2nd eye. Running a one-man-show is really difficult and you were my partner in crime today.
Thanks:-) In my Outlook, Copilot summarizes this thread like this:
Pretty nice
Describe the issue Running New-BCContainer without specifying the license after reinstalling BcContainerHelper, per Freddydk
Scripts used to create container and cause the issue
Full output of scripts
Additional context