I need to use the official PowerShell Core Docker image to run a Docker container and make it execute a PowerShell script file.
I know it can be done using a Dockerfile and Docker build, but can't use that in this case.
From reading docs I came up with this, but it does not seem to work:
docker run -it --rm --entrypoint "/tmp/test.ps1" repo/powershell:latest
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"/tmp/test.ps1\": stat /tmp/test.ps1: no such file or directory": unknown.
ERRO[0001] error waiting for container: context canceled
Error seems to say that it can't find the file but when running stat "/tmp/test.ps1"
manually it works fine.
I feel like the binary pwsh
should also be specified but can't find a way how to do it.
docker run -it repo/powershell:latest /tmp/test.ps
and since you don't need to stay inside-it
is not required – Voluptuousdocker run repo/powershell:latest /tmp/test.ps1 docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"/tmp/test.ps1\": stat /tmp/test.ps1: no such file or directory": unknown.
– Waylonstat
command afterwards:rob@linuxvm:/tmp$ stat /tmp/test.ps1 File: /tmp/test.ps1 Size: 32 Blocks: 8 IO Block: 4096 regular file Device: 802h/2050d Inode: 931983 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1000/ rob) Gid: ( 1000/ rob) Access: 2019-11-26 15:55:56.966119943 +0000 Modify: 2019-11-26 15:56:07.951610246 +0000 Change: 2019-11-26 15:56:07.951610246 +0000 Birth: -
– Waylonstat /tmp/test.ps1: no such file or directory
powershell - means windows, and that means that/tmp/test.ps1
is not an absolute path from root. If so you should try something likeC:\bla\bla\another_bla\tmp\test.ps1
– Voluptuous