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
Dockerfile在基于Ubuntu的映像上运行调用powershell_Powershell_Docker_Dockerfile - Fatal编程技术网

Dockerfile在基于Ubuntu的映像上运行调用powershell

Dockerfile在基于Ubuntu的映像上运行调用powershell,powershell,docker,dockerfile,Powershell,Docker,Dockerfile,我的Dockerfile中有以下内容: # setup powershell # Download the Microsoft repository GPG keys RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb # Register the Microsoft repository GPG keys RUN dpkg -i packages-microsoft

我的Dockerfile中有以下内容:

# setup powershell
# Download the Microsoft repository GPG keys
RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
RUN dpkg -i packages-microsoft-prod.deb
# Update the list of products
RUN apt-get update && apt-get install -y \
    libunwind8 \
    libicu55 \
    powershell
# Register Powershell repo
RUN powershell Register-PSRepository ...
根据我读到的所有内容,这应该是可行的,但是我在docker构建期间得到了以下输出(使用敏感信息进行审查)

处理libc bin(2.23-0ubuntu11)的触发器。。。
设置liburcu4:amd64(0.9.1-3)。。。
正在设置liblttng-ust-ctl2:amd64(2.7.1-1)。。。
设置liblttng-ust0:amd64(2.7.1-1)。。。
正在设置powershell(7.0.0-1.ubuntu.16.04)。。。
正在处理libc bin(2.23-0ubuntu11)的触发器。。。
拆卸中间容器1ef0413ecd13
--->a5323d6c8301
步骤12/23:运行powershell注册PSRepository。。。。。。
--->在604784872cc8中运行
/bin/sh:1:powershell:未找到
命令“/bin/sh-c powershell Register PSRepository…”。。。。。。返回一个非零代码:127
我不知道为什么找不到powershell,因为
apt get install
调用它是成功的


在使用
apt get
成功安装后,如何调用
powershell

在安装powershell后,您应该能够使用

pwsh


从本博客中发现,可执行文件的名称从5.1更改为6.0(又名Powershell Core):

  • 适用于Windows上的Powershell v1.0-5.1-
    Powershell.exe
  • 对于Windows上的Powershell v6.0+-
    pwsh.exe
    ,在MacOS和Linux上作为
    pwsh
    调用
所以正确的说法是:

RUN pwsh -Command Register-PSRepository ... <etc>
运行pwsh-命令寄存器PSRepository。。。
RUN pwsh -Command Register-PSRepository ... <etc>