Php docker中powercli的安装问题
我已经在php docker映像上安装了PowerShell,现在正在尝试安装VMWare PowerCLI 我在第44行遇到以下错误Php docker中powercli的安装问题,php,docker,powershell,dockerfile,powercli,Php,Docker,Powershell,Dockerfile,Powercli,我已经在php docker映像上安装了PowerShell,现在正在尝试安装VMWare PowerCLI 我在第44行遇到以下错误 ParserError: Line | 1 | Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP -Confirm: | ~ | P
ParserError:
Line |
1 | Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP -Confirm:
| ~
| Parameter -Confirm: requires an argument.
ERROR: Service 'app' failed to build: The command '/bin/sh -c pwsh -c "Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false -Confirm:$false"' returned a non-zero code: 1
第44行:运行pwsh-c“设置PowerCLIConfiguration-作用域用户-参与者IP$false-确认:$false”
这是我的docker文件
FROM php:7.4-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libonig-dev \
locales \
libzip-dev \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl \
wget \
apt-utils
# Download the Microsoft repository GPG keys
RUN wget https://packages.microsoft.com/config/debian/10/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
# Install PowerShell
RUN apt-get install -y powershell
# Start PowerShell
#RUN pwsh
#Install VMWare PowerCLI
RUN pwsh -c "Install-Module -Name VMware.PowerCLI -Scope CurrentUser"
RUN pwsh -c "Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false -Confirm:$false"
RUN pwsh -c "Set-PowerCLIConfiguration -Scope User -InvalidCertificateAction Ignore"
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl mysqli
RUN docker-php-ext-configure gd --enable-gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/
RUN docker-php-ext-install gd
RUN docker-php-ext-enable mysqli
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
我想不出怎么解决。非常感谢您的帮助
更新
要删除前面的错误,我使用了0而不是$false
dockerfile的修改内容如下:
FROM php:7.4-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libonig-dev \
locales \
libzip-dev \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl \
wget \
apt-utils
# Download the Microsoft repository GPG keys
RUN wget https://packages.microsoft.com/config/debian/10/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
# Install PowerShell
RUN apt-get install -y powershell
# Start PowerShell
#RUN pwsh
#Install VMWare PowerCLI
RUN pwsh -c "Save-Module -Name VMware.PowerCLI -Path ~/"
RUN pwsh -c "Install-Module -Name VMware.PowerCLI -Scope CurrentUser -Force"
RUN pwsh -c "Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP 0 -Confirm:0"
RUN pwsh -c "Set-PowerCLIConfiguration -Scope User -InvalidCertificateAction Ignore -Confirm:0"
RUN pwsh -c "Get-Module -ListAvailable VMware.PowerCLI"
RUN pwsh -c "Import-Module VMware.PowerCLI"
现在错误如下:
Exception: VMware.VimAutomation.HorizonView module is not currently supported on the Core edition of PowerShell.
ERROR: Service 'app' failed to build: The command '/bin/sh -c pwsh -c "Import-Module VMware.PowerCLI"' returned a non-zero code: 1
如果没有VMware.VimAutomation.HorizonView和其他依赖项,似乎无法安装整个PowerCLI模块 因此,我没有将整个PowerCLI及其从属模块作为一个整体安装,而是将所需模块安装为:
运行pwsh-Command Get Module-ListAvailable VMware.VimAutomation.Core |导入模块
或者,您也可以使用以下命令仅导入所需的模块。感谢:
运行pwsh-命令“导入模块-名称VMware.VimAutomation.Core-范围CurrentUser”
这就解决了问题。尝试禁用模块:是。我看过这篇文章。我在用docker。因此,当我重新启动容器时,更改将丢失。是否有一种方法可以在dockerfile中执行此操作?在dockerfile(在图像中)中配置,而不是在容器中配置我不确定如何执行此操作?
运行pwsh-c导入模块VMware.PowerCLI-ErrorAction Continue
也会失败