nilosch
nilosch

Reputation: 162

'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?

Upvotes: 0

Views: 339

Answers (2)

nilosch
nilosch

Reputation: 162

This works:

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

Upvotes: 1

ozs
ozs

Reputation: 3651

in power shell you need to use | (pipe) to continue commands

docker cp ../from-here/. | % {docker ps -aqf "name=my-ending$"}:/to-here

Upvotes: 0

Related Questions