![](/img/trans.png)
[英]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.