RUN Powershell Script in Docker Container From Host Powershell Script

Usa*_*eem 2 powershell docker

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"
Run Code Online (Sandbox Code Playgroud)

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

arc*_*444 6

不要使用-ti标志来启动交互式会话,只需通过docker exec命令直接执行脚本

docker exec website powershell -command "C:\inetpub\wwwroot\addApplication.ps1"
Run Code Online (Sandbox Code Playgroud)