将文件复制到 Azure 上下文中的 Docker 卷

Copy file to Docker volume in Azure context

我 运行 这些 docker 命令在本地将文件复制到卷,这工作正常:

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

现在我想做同样的事情,但卷位于 Azure 中。我有一个我推送的图像 azureimage,它位于 Azure 中,我需要从容器访问一个包含我本地磁盘中的文件的卷。

我可以像这样在 Azure 上下文中创建卷:

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

但是当我尝试将文件复制到容器指向的卷时:

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

我了解到无法在 Azure 上下文中执行容器和复制命令:

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

如何将文件从我的本地磁盘复制到 Azure 上下文中的卷?我必须先将它上传到 Azure 吗?我必须将它复制到文件共享吗?

据我所知,当您将 Azure 文件共享挂载到 ACI 时,您应该将文件上传到文件共享中,并且文件将存在于您挂载的容器实例中。您可以使用 Azure CLI 命令 az storage file upload or AzCopy 上传文件。

命令docker cp 旨在在容器和本地文件系统之间复制files/folders。但文件共享位于 Azure 存储中,而不是本地。而且容器也在 Azure ACI 中。