在Azure上下文中将文件复制到Docker卷 [英] Copy file to Docker volume in Azure context

查看:51
本文介绍了在Azure上下文中将文件复制到Docker卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地运行以下docker命令以将文件复制到卷中,效果很好:

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/.

现在,我想执行同样的操作,但是卷位于Azure中.我有一个推送的图像 azureimage ,它位于Azure中,我需要从容器访问一个包含本地磁盘中文件的卷.

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.

我可以在Azure上下文中创建卷,如下所示:

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/.

我发现容器和复制命令无法在Azure上下文中执行:

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

命令容器";在当前上下文(azaci)中不可用,您可以使用默认"运行此命令的上下文

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

命令"cp"在当前上下文(azaci)中不可用,您可以使用默认"运行此命令的上下文

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

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

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?

推荐答案

据我所知,当您将Azure文件共享安装到ACI时,应将文件上传到文件共享中,并且文件将存在于容器中您安装的实例.您可以使用Azure CLI命令 az存储文件上传 AzCopy 上传文件.

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.

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

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.

这篇关于在Azure上下文中将文件复制到Docker卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆