Dockerfile (Windows): Chocolatey выдает ошибку «не распознано как имя командлета» после установки nvm

Я пытаюсь установить NVM в свой контейнер, сначала установив Chocolatey. Проблема, с которой я сталкиваюсь, заключается в том, что при создании контейнера после установки nvm через шоколад, когда я пытаюсь запустить команду «nvm», чтобы проверить, была ли она установлена, я получаюnvm : The term 'nvm' is not recognized as the name of a cmdletошибка.

Мой докерфайл выглядит следующим образом:

      # escape=`

#Use the latest Windows Server Core 2019 image.
FROM mcr.microsoft.com/windows/servercore:ltsc2019

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

#Adding Chocolatey (a windows package manager)
RUN powershell Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

RUN powershell Get-ChildItem Env:

#Using Chocolatey to install nvm (Node Version Manager) 
RUN choco install -y nvm

RUN powershell Import-Module C:\ProgramData\chocolatey\helpers\chocolateyProfile.psm1
RUN powershell refreshenv
RUN powershell nvm

ENTRYPOINT powershell

Вот результат моегоdocker build -t dockeragent:latest --no-cache .команда

      PS C:\docker\dockeragent> docker build -t dockeragent:latest --no-cache .
Sending build context to Docker daemon  751.1MB
Step 1/9 : FROM mcr.microsoft.com/windows/servercore:ltsc2019
 ---> e795f3f8aa80
Step 2/9 : SHELL ["cmd", "/S", "/C"]
 ---> Running in d7dc5ed6ce89
Removing intermediate container d7dc5ed6ce89
 ---> c7dc93b631eb
Step 3/9 : RUN powershell Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
 ---> Running in 369cfe083374
Forcing web requests to allow TLS v1.2 (Required for requests to Chocolatey.org)
Getting latest version of the Chocolatey package for download.
Not using proxy.
Getting Chocolatey from https://community.chocolatey.org/api/v2/package/chocolatey/1.2.0.
Downloading https://community.chocolatey.org/api/v2/package/chocolatey/1.2.0 to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip
Not using proxy.
Extracting C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall
Installing Chocolatey on the local machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
  Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
  before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
  (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
  and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.

Creating Chocolatey folders if they do not already exist.

WARNING: You can safely ignore errors related to missing log files when
  upgrading from a version of Chocolatey less than 0.9.9.
  'Batch file could not be found' is also safe to ignore.
  'The system cannot find the file specified' - also safe.
chocolatey.nupkg file not installed in lib.
 Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
WARNING: Not setting tab completion: Profile file does not exist at
'C:\Users\ContainerAdministrator\Documents\WindowsPowerShell\Microsoft.PowerShe
ll_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
 first prior to using choco.
Ensuring Chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder
Removing intermediate container 369cfe083374
 ---> 6d782b624394
Step 4/9 : RUN powershell Get-ChildItem Env:
 ---> Running in 66fa6d3c8dc1

Name                           Value
----                           -----
ALLUSERSPROFILE                C:\ProgramData
APPDATA                        C:\Users\ContainerAdministrator\AppData\Roaming
ChocolateyInstall              C:\ProgramData\chocolatey
ChocolateyLastPathUpdate       133118979019612509
CommonProgramFiles             C:\Program Files\Common Files
CommonProgramFiles(x86)        C:\Program Files (x86)\Common Files
CommonProgramW6432             C:\Program Files\Common Files
COMPUTERNAME                   66FA6D3C8DC1
ComSpec                        C:\Windows\system32\cmd.exe
DriverData                     C:\Windows\System32\Drivers\DriverData
LOCALAPPDATA                   C:\Users\ContainerAdministrator\AppData\Local
NUMBER_OF_PROCESSORS           4
OS                             Windows_NT
Path                           C:\Windows\system32;C:\Windows;C:\Windows\Sys...
PATHEXT                        .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;....
PROCESSOR_ARCHITECTURE         AMD64
PROCESSOR_IDENTIFIER           Intel64 Family 6 Model 62 Stepping 4, Genuine...
PROCESSOR_LEVEL                6
PROCESSOR_REVISION             3e04
ProgramData                    C:\ProgramData
ProgramFiles                   C:\Program Files
ProgramFiles(x86)              C:\Program Files (x86)
ProgramW6432                   C:\Program Files
PROMPT                         $P$G
PSModulePath                   C:\Users\ContainerAdministrator\Documents\Win...
PUBLIC                         C:\Users\Public
SystemDrive                    C:
SystemRoot                     C:\Windows
TEMP                           C:\Users\ContainerAdministrator\AppData\Local...
TMP                            C:\Users\ContainerAdministrator\AppData\Local...
USERDOMAIN                     User Manager
USERNAME                       ContainerAdministrator
USERPROFILE                    C:\Users\ContainerAdministrator
windir                         C:\Windows


Removing intermediate container 66fa6d3c8dc1
 ---> b4ecb9d7464b
Step 5/9 : RUN choco install -y nvm
 ---> Running in 19f770d7871d
Chocolatey v1.2.0
Installing the following packages:
nvm
By installing, you accept licenses for the packages.
Progress: Downloading nvm.install 1.1.9... 100%
Progress: Downloading nvm 1.1.9... 100%

nvm.install v1.1.9 [Approved]
nvm.install package files install completed. Performing other installation steps.
Downloading nvm.install
  from 'https://github.com/coreybutler/nvm-windows/releases/download/1.1.9/nvm-setup.zip'
Progress: 100% - Completed download of C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\nvm.install\1.1.9\nvm-setup.zip (4.14 MB).
Download of nvm-setup.zip (4.14 MB) completed.
Hashes match.
Extracting C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\nvm.install\1.1.9\nvm-setup.zip to C:\ProgramData\chocolatey\lib\nvm.install\tools...
C:\ProgramData\chocolatey\lib\nvm.install\tools
C:\ProgramData\chocolatey\lib\nvm.install\tools\nvm-setup.exe.ignore
 The install of nvm.install was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\nvm.install\tools'

nvm v1.1.9 [Approved]
nvm package files install completed. Performing other installation steps.
 The install of nvm was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\nvm'

Chocolatey installed 2/2 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Removing intermediate container 19f770d7871d
 ---> f8b42ae67241
Step 6/9 : RUN powershell Import-Module C:\ProgramData\chocolatey\helpers\chocolateyProfile.psm1
 ---> Running in 26740393fea3
Removing intermediate container 26740393fea3
 ---> 00698d7e89a9
Step 7/9 : RUN powershell refreshenv
 ---> Running in b2b437ce5170
Refreshing environment variables from registry for cmd.exe. Please wait...Finished..
Removing intermediate container b2b437ce5170
 ---> 00e6e3e82e62
Step 8/9 : RUN powershell nvm
 ---> Running in d23b3bd9f50f
nvm : The term 'nvm' 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
+ nvm
+ ~~~
    + CategoryInfo          : ObjectNotFound: (nvm:String) [], CommandNotFound
   Exception
    + FullyQualifiedErrorId : CommandNotFoundException

The command 'cmd /S /C powershell nvm' returned a non-zero code: 1

Моя хост-среда основана на кластере Manage Mirantis Container Cloud (Mirantis Inc., v1.9.0)

и это результат моегоdocker infoкоманда

      Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker Application (Docker Inc., v0.8.0)
  cluster: Manage Mirantis Container Cloud clusters (Mirantis Inc., v1.9.0)
  registry: Manage Docker registries (Docker Inc., 0.1.0)

0 ответов

Другие вопросы по тегам