RUN Powershell Script in Docker Container From Host Powershell Script

落爺英雄遲暮 提交于 2021-02-07 08:11:12

问题


I have a powershell script in host which copy some files and starts the container.

#Copy File
docker cp "D:\addApplication.ps1" website:/inetpub/wwwroot/

#Start Container
docker start website
Write-Host 'Process has started'

#Execute Container
docker exec -ti website powershell

#Run Script
Invoke-Expression "C:\inetpub\wwwroot\addApplication.ps1"

Second last command executes fine but last command will only execute when I exit the container session and returns error(File Not Found which is because it finds that file on host)

Question: Is there anyway I can execute the command in container session from the script. Or execute any command from script in any process(confused)

Any help is appreciated.

Thanks


回答1:


Do not use the -ti flags to start an interactive session, just execute the script directly via the docker exec command

docker exec website powershell -command "C:\inetpub\wwwroot\addApplication.ps1"


来源:https://stackoverflow.com/questions/47828162/run-powershell-script-in-docker-container-from-host-powershell-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!