我的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 build
期间得到以下输出(使用敏感信息进行审查(。
Processing triggers for libc-bin (2.23-0ubuntu11) ...
Setting up liburcu4:amd64 (0.9.1-3) ...
Setting up liblttng-ust-ctl2:amd64 (2.7.1-1) ...
Setting up liblttng-ust0:amd64 (2.7.1-1) ...
Setting up powershell (7.0.0-1.ubuntu.16.04) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
Removing intermediate container 1ef0413ecd13
---> a5323d6c8301
Step 12/23 : RUN powershell Register-PSRepository ...<snip>...
---> Running in 604784872cc8
/bin/sh: 1: powershell: not found
The command '/bin/sh -c powershell Register-PSRepository ...<snip>... returned a non-zero code: 127
我不知道为什么没有找到powershell,因为apt-get install
呼吁它是成功的。
使用apt-get
成功安装后如何调用powershell
?
安装 powershell 后,您应该能够使用
普华永道
从此博客中发现,可执行文件的名称从 5.1 更改为 6.0(又名 Powershell Core(:https://www.starwindsoftware.com/blog/using-powershell-on-linux
- 适用于 Powershell v1.0 - 5.1 - Windows 上的
powershell.exe
- 对于 Powershell v6.0+ - Windows 上的
pwsh.exe
,在 MacOS 和 Linux 上作为pwsh
调用
所以正确的调用是:
RUN pwsh -Command Register-PSRepository ... <etc>