Some more common Docker setup errors and solutions

One of the common errors working with Sitecore CLI is openid-configuration error caused by Sitecore CLI unable to access the CM instance, here is a diagrammatic representation of some of the probable reasons:

Error:

.\init.ps1 : File C:\projects\cms-project\init.ps1 cannot be loaded. The file C:\projects\cms-project\init.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

At line:1 char:1

Solution: Since this is a generic error for all files you unzipped from a zip file created on another machine, unblock the concerned file:


Error:

 => ERROR [internal] load metadata for mcr.microsoft.com/windows/nanoserver:1809                                   0.9s

 => CANCELED [internal] load metadata for mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019    0.9s

------

 > [internal] load metadata for mcr.microsoft.com/windows/nanoserver:1809:

------

failed to solve with frontend dockerfile.v0: failed to create LLB definition: no match for platform in manifest sha256:c827903a303cb7a76214adb4376e462a241b3cd763cb88655cd901c5a0e867a0: not found

ERROR: Service 'solution' failed to build : Build failed

Solution:

I did two things but the second one is correct solution for the issue:

Install .NET Framework 4.8 Developer Pack (less likely)

Switch to Windows Container in Docker Desktop (most likely)

Error

Invoke-WebRequest : The remote name could not be resolved: 'dist.nuget.org'

At line:1 char:76

+ ... yContinue'; Invoke-WebRequest https://dist.nuget.org/win-x86-commandl ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:Htt

   pWebRequest) [Invoke-WebRequest], WebException

    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -UseBasicParsing -OutFile "$env:ProgramFiles\NuGet\nuget.exe"' returned a non-zero code: 1

ERROR: Service 'solution' failed to build : Build failed

Solution:

Since the url - https://dist.nuget.org/win-x86-commandline/latest/nuget.exe was accessible from browser, resolved by  adding "dns":["8.8.8.8"to Docker Settings as per StackOverflow response 


Error:

Error connecting to https://id.basic-company-nextjs.localhost/.well-known/openid-configuration: The SSL connection could not be established, see inner exception.
C:\projects\cms-project\up.ps1 : Unable to log into Sitecore, did the Sitecore environment start correctly? See logs above.
At line:1 char:1
+ .\up.ps1
+ ~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,up.ps1

Solution:

There are many reasons for this error but one main reason, as specified in my other blog, could be if you didn't generate the certs for traefik and they are not present under docker\traefik\certs folder. In other words, in one of my scenarios, I didn't run .\init.ps1 before .\up.ps1 since my .env file was from code repo and so was already pre-filled with necessary values!

Just for reference this is how cert generation section in up.ps1 looks like, could extract this and add to a separate ps1 file and run the same, ensure the host file entries match the entries in line where $mkcert is invoked:

##################################
# Configure TLS/HTTPS certificates
##################################

Push-Location docker\traefik\certs
try {
    $mkcert = ".\mkcert.exe"
    if ($null -ne (Get-Command mkcert.exe -ErrorAction SilentlyContinue)) {
        # mkcert installed in PATH
        $mkcert = "mkcert"
    } elseif (-not (Test-Path $mkcert)) {
        Write-Host "Downloading and installing mkcert certificate tool..." -ForegroundColor Green 
        Invoke-WebRequest "https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-windows-amd64.exe" -UseBasicParsing -OutFile mkcert.exe
        if ((Get-FileHash mkcert.exe).Hash -ne "1BE92F598145F61CA67DD9F5C687DFEC17953548D013715FF54067B34D7C3246") {
            Remove-Item mkcert.exe -Force
            throw "Invalid mkcert.exe file"
        }
    }
    Write-Host "Generating Traefik TLS certificate..." -ForegroundColor Green
    & $mkcert -install
    & $mkcert "*.basic-company-nextjs.localhost"
    & $mkcert "*.xxxxxx.localhost"

    # stash CAROOT path for messaging at the end of the script
    $caRoot = "$(& $mkcert -CAROOT)\rootCA.pem"
}
catch {
    Write-Error "An error occurred while attempting to generate TLS certificate: $_"
}
finally {
    Pop-Location
}

Error:
Invalid template: ".s[-U.MP[X_zweAXn^AHcqj@?OUc::MrW\\7}7+C&Cfs<hiC<F<+V$7Z&BHFnje@Y?7ZmwLPk^=MWJ4CFS^;5oVzPtw"

Solution:
Uncheck Docker Compose V2 in Docker settings



Comments

Popular Posts