dockerpowershelldocker-for-windowsparameter-expansiondocker-cp

'Docker cp' with parameter expansion (PowerShell)


I want to copy a directory into a docker container, which is only defined by a certain query. I tried this:

docker cp ../from-here/. $(docker ps -aqf "name=my-ending$"):/to-here

Unforunately this throws this error:

"docker cp" requires exactly 2 arguments.

Running the same command with pasting the real Container ID works.

It seems, that PowerShell in combination with Docker doesn't allow parameter expansion.

Is there an easy work around for this problem in a single line?


Solution

  • This works:

    docker @("cp", "../from-here/.", "$(docker ps -aqf "name=my-ending$"):/to-here")