[英]Execute docker run through powershell script (Windows 10)
[英]How to execute PowerShell script in Windows-container under Docker?
下面是我的entrypoint.ps1
( PowerShell -script):
Set-Location -Path C:\nginx
& "C:\nginx\Configure-Nginx.ps1"
& "C:\nginx\nginx.exe"
我需要在docker run
时执行我的Configure-Nginx.ps1
和node.exe
,所以我在Dockerfile
中放置了一个入口点:
FROM nginx
# nginx is a custom image that's based on mcr.microsoft.com/windows/servercore:1809-KB5003171
COPY entrypoint.ps1 ./
COPY install/Configure-Nginx.ps1 /nginx/Configure-Nginx.ps1
ENTRYPOINT ["powershell", "entrypoint.ps1"]
但是我的容器每分钟都开始重新启动......好吧,我已经确定脚本中有一些错误然后我使用--entrypoint powershell
手动运行此映像并直接在控制台中执行我的脚本: .\entrypoint.ps1
. 脚本被冻结(因为nginx
已启动),我可以从主机上的网络浏览器连接到我的容器......所以一切正常! 那么,如果我从Dockerfile
调用我的入口点,为什么它不起作用? 有什么区别? 也许有人遇到过类似的问题......
PS容器基于mcr.microsoft.com/windows/servercore:1809-KB5003171
和PowerShell v5.1.17763.1852
首先确保脚本在容器根目录下可用:
COPY entrypoint.ps1 /entrypoint.ps1
然后通过-Command
或-File
执行它:
ENTRYPOINT ["pwsh", "-Command", "/entrypoint.ps1"]
ENTRYPOINT ["pwsh", "-File","/entrypoint.ps1"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.