Docker에 powercli 설치 문제

Nov 19 2020

PHP Docker 이미지에 PowerShell을 설치했으며 이제 VMWare PowerCLI를 설치하려고합니다. 44 행에 다음 오류가 표시됩니다.

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 행 : RUN pwsh -c "Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false -Confirm:$false"

이것은 내 도커 파일입니다.

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"]

어떻게 해결해야할지 모르겠습니다. 어떤 도움이라도 대단히 감사합니다.

업데이트 이전 오류를 제거하기 위해 $ false 대신 0을 사용했습니다. 수정 된 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

답변

Vamshi Nov 22 2020 at 16:31

VMware.VimAutomation.HorizonView 및 기타 종속성이 없으면 전체 PowerCLI 모듈을 설치할 수 없습니다.

따라서 전체 PowerCLI 및 종속 모듈 전체를 설치하는 대신 다음과 같이 필요한 모듈 만 설치했습니다.

RUN pwsh -Command Get-Module -ListAvailable VMware.VimAutomation.Core | Import-Module.

또는 아래를 사용하여 필요한 모듈 만 가져올 수도 있습니다. Scepticalist 에게 감사드립니다 .

RUN pwsh -Command 'Import-Module -Name VMware.VimAutomation.Core -Scope CurrentUser'

이것은 문제를 해결합니다.