Copy file to Docker volume in Azure context

无人久伴 提交于 2020-12-15 02:07:01

问题


I run these docker commands locally to copy a file to a volume, this works fine:

docker container create --name temp_container -v temp_vol:/target hello-world
docker cp somefile.txt temp_container:/target/.

Now I want to do the same, but with volumes located in Azure. I have an image azureimage that I pushed and it's located in Azure, and I need to access from the container a volume with a file that I have in my local disk.

I can create the volume in an Azure context like so:

docker context use azaci
docker volume create test-volume --storage-account mystorageaccount

But when I try to copy a file to the volume pointed by a container:

docker context use azaci
docker container create --name temp_container2 -v test-volume:/target azureimage
docker cp somefile.txt temp_container2:/target/.

I get that the container and copy commands cannot be executed in the Azure context:

Command "container" not available in current context (azaci), you can use the "default" context to run this command

Command "cp" not available in current context (azaci), you can use the "default" context to run this command

How to copy a file from my local disk to volume in Azure context? Do I have to upload it to Azure first? Do I have to copy it to the file share?


回答1:


As I know, when you mount the Azure File Share to the ACI, then you should upload the files into the File Share and the files will exist in the container instance that you mount. You can use the Azure CLI command az storage file upload or AzCopy to upload the files.

The command docker cp aims to copy files/folders between a container and the local filesystem. But the File Share is in the Azure Storage, not local. And the container is also in the Azure ACI.



来源:https://stackoverflow.com/questions/64993171/copy-file-to-docker-volume-in-azure-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!