Dockerfile复制保持子目录结构 [英] Dockerfile copy keep subdirectory structure
本文介绍了Dockerfile复制保持子目录结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将多个文件和文件夹从本地主机复制到docker映像构建中。
I'm trying to copy a number of files and folders to a docker image build from my localhost.
文件如下:
folder1
file1
file2
folder2
file1
file2
我正在尝试制作这样的副本:
I'm trying to make the copy like this:
COPY files/* /files/
但是,所有文件都是放置在/ files /中,Docker中是否可以保留子目录结构以及将文件复制到其目录中?
However, all files are placed in /files/ is there a way in Docker to keep the subdirectory structure as well as copying the files into their directories?
推荐答案
使用以下Dockerfile从COPY中删除星号:
Remove star from COPY, with this Dockerfile:
FROM ubuntu
COPY files/ /files/
RUN ls -la /files/*
结构在那里:
$ docker build .
Sending build context to Docker daemon 5.632 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu
---> d0955f21bf24
Step 1 : COPY files/ /files/
---> 5cc4ae8708a6
Removing intermediate container c6f7f7ec8ccf
Step 2 : RUN ls -la /files/*
---> Running in 08ab9a1e042f
/files/folder1:
total 8
drwxr-xr-x 2 root root 4096 May 13 16:04 .
drwxr-xr-x 4 root root 4096 May 13 16:05 ..
-rw-r--r-- 1 root root 0 May 13 16:04 file1
-rw-r--r-- 1 root root 0 May 13 16:04 file2
/files/folder2:
total 8
drwxr-xr-x 2 root root 4096 May 13 16:04 .
drwxr-xr-x 4 root root 4096 May 13 16:05 ..
-rw-r--r-- 1 root root 0 May 13 16:04 file1
-rw-r--r-- 1 root root 0 May 13 16:04 file2
---> 03ff0a5d0e4b
Removing intermediate container 08ab9a1e042f
Successfully built 03ff0a5d0e4b
这篇关于Dockerfile复制保持子目录结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文