简体   繁体   English

如何在 Windows docker 映像上安装 PHP 作曲家?

[英]How to install PHP composer on Windows docker image?

I am trying to install Composer on a Windows Docker image我正在尝试在 Windows Docker 图像上安装 Composer

Dockerfile is provided below Dockerfile 提供如下

FROM mcr.microsoft.com/windows/servercore:ltsc2019

RUN powershell.exe Invoke-WebRequest -Uri "https://getcomposer.org/installer" -OutFile composer-setup.php
RUN powershell.exe Start-Process -FilePath "php.exe" -ArgumentList composer-setup.php

However, when I build the docker image it does NOT either install composer or throw any error但是,当我构建 docker 映像时,它既不会安装composer ,也不会引发任何错误

I tried to install composer setup using the following methods but none worked我尝试使用以下方法安装作曲家设置,但没有奏效

1)  RUN powershell.exe Start-Process -FilePath "php.exe" -ArgumentList composer-setup.php
2)  RUN powershell.exe Invoke-Expression "'php.exe composer-setup.php'"
3)  RUN powershell.exe Invoke-Expression "php.exe composer-setup.php"
4)  RUN powershell.exe Invoke-Expression -Command "'php.exe composer-setup.php'"
5)  RUN powershell.exe Invoke-Expression "& 'php.exe' composer-setup.php"  - & not allowed error message

Kindly let me know how to execute php.exe composer-setup.php using Powershell or CMD from within the Docker container. Kindly let me know how to execute php.exe composer-setup.php using Powershell or CMD from within the Docker container.

EDIT编辑

I connected to docker image我连接到 docker 图像

PS C:\Users> docker run -it myphp:latest
Microsoft Windows [Version 10.0.17763.1935]
(c) 2018 Microsoft Corporation. All rights reserved.

and executed the following but nothing happened instead it returned to prompt并执行了以下操作,但什么也没发生,而是返回提示

C:\Softwares\Composer>php.exe composer-setup.php
'php.exe' is not recognized as an internal or external command,
operable program or batch file.

C:\Softwares\Composer>C:\Softwares\PHP\php.exe composer-setup.php

C:\Softwares\Composer>

I added the following to Dockerfile and it worked fine我将以下内容添加到 Dockerfile 并且效果很好

ADD vcruntime140.dll C:\\Windows\\System32\\vcruntime140.dll

Unlike Windows host machine (where DLLs exists by default) we need to explicitly add the requires DLLs to Docker与 Windows 主机(默认情况下存在 DLL)不同,我们需要将所需的 DLL 显式添加到 Docker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM