How to Copy Data from Host to Named Volume on Windows

I am trying to copy existing data from my host machine into a Windows Volume.

I have found instructions that work for linux, but not on windows. Here are the linux instructions, as found here:
docker container create --name dummy -v myvolume:/root hello-world
docker cp c:\myfolder\myfile.txt dummy:/root/myfile.txt
docker rm dummy

On Windows, I have to change the volume declaration to:
container create --name dummy -v myvolume:C:/root hello-world
Otherwise, I get this error message:
Error response from daemon: invalid volume specification: ‘myvolume:/root’

Once the container has been properly created, the copy command fails:
docker cp C:\Users\local_user\Documents\Docker\hello-world.txt dummy:C:\root\myfile.txt
Error Message:
Error: No such container:path: dummy:C:\root

Any assistance would be greatly appreciated.

To copy existing data from your host machine into a Windows volume, you can use the following steps:

  1. Create a container using the following command: docker container create --name dummy -v myvolume:C:/root hello-world

Note that the volume declaration has been changed to “myvolume:C:/root” for Windows.

  1. Start the container: docker start dummy
  2. Copy the file from your host machine into the container using the following command: docker cp C:\Users\local_user\Documents\Docker\hello-world.txt dummy:/root/myfile.txt

Note that the path to the destination directory in the container is now “/root/myfile.txt” for Windows.

  1. Stop and remove the container: docker stop dummy docker rm dummy

After following these steps, the file “hello-world.txt” should be copied into the “myvolume” volume in the container.

I have just found this topic. I am going to close it, since we discussed it in a newer topic. Please, don’t create multiple topics for the same question and don’t post into the “Community” category unless you have question “about” the community (I moved it to Docker DEsktop for Windows).