首页 > 解决方案 > Dockerfile RUN 在基于 Ubuntu 的映像上调用 powershell

问题描述

我的 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因为它的呼吁是成功的。

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

标签: powershelldockerdockerfile

解决方案


安装 powershell 后,您应该可以使用它来调用它

密码


推荐阅读