Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 如何使用docker文件在docker容器内安装powershell模块_Windows_Docker_Powershell_Containers - Fatal编程技术网

Windows 如何使用docker文件在docker容器内安装powershell模块

Windows 如何使用docker文件在docker容器内安装powershell模块,windows,docker,powershell,containers,Windows,Docker,Powershell,Containers,我有一个基本的powershell脚本,可以对SharePoint online(Office365)进行更改。此任务要求在要执行脚本的系统中安装Microsoft.Online.SharePoint.PowerShell模块 下面是我的docker文件: FROM mcr.microsoft.com/powershell:latest WORKDIR ./ CMD pwsh -Command Install-Module Microsoft.Online.SharePoint.PowerS

我有一个基本的powershell脚本,可以对SharePoint online(Office365)进行更改。此任务要求在要执行脚本的系统中安装Microsoft.Online.SharePoint.PowerShell模块

下面是我的docker文件:

FROM mcr.microsoft.com/powershell:latest

WORKDIR ./

CMD pwsh -Command Install-Module Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser -Force

COPY SampleScript.ps1 ./

CMD pwsh .\SampleScript.ps1
当我跑步时:

docker运行——名称为“pwsh演示”——交互式——tty dockerdemo

我无法进入交互模式。但当我试图手动进入容器并在不使用dockerfile的情况下手动安装模块时,模块正在安装,但当我运行脚本时,它抛出错误,表示:

The term 'Connect-SPOService' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is
     | correct and try again.
虽然模块已安装,但我使用以下命令进行了验证:

获取模块-列表可用