如何将文件夹从Dockerfile复制到Docker映像? [英] How to copy folders to docker image from Dockerfile?

查看:646
本文介绍了如何将文件夹从Dockerfile复制到Docker映像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Dockerfile中尝试了以下命令: COPY * / 并对结果感到惊讶。似乎朴素的docker代码从glob中遍历目录,然后将每个文件转储到目标目录中,同时尊重我的目录结构。

I tried the following command in my Dockerfile: COPY * / and got mighty surprised at the result. Seems the naive docker code traverses the directories from the glob and then dumps the each file in the target directory while respectfully ignoring my directory structure.

至少这就是我的理解这票证,它肯定与我得到的结果相对应。

At least that is how I understand this ticket and it certainly corresponds to the result I got.

我猜想这种行为仍然存在的唯一原因必须是还有其他方法可以做到。但是,只有极少的大脑来了解怎么回事并不容易,有人知道吗?

I guess the only reason this behavior can still exist must be that there is some other way this should be done. But it is not so easy for a bear of very little brain to understand how, does anyone know?

推荐答案

就像@Vonc说的那样,到目前为止,不可能添加任何命令。唯一的解决方法是提及文件夹,然后创建它并向其中添加内容。

Like @Vonc said, there is no possibility to add a command like as of now. The only workaround is to mention the folder, to create it and add contents to it.

# add contents to folder
ADD src $HOME/src

将在其中创建一个名为 src 的文件夹您的目录,并将文件夹 src 的内容添加到其中。

Would create a folder called src in your directory and add contents of your folder src into this.

这篇关于如何将文件夹从Dockerfile复制到Docker映像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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