我正在尝试从我的本地主机将一些文件和文件夹复制到docker镜像构建中。
文件如下所示:
folder1
file1
file2
folder2
file1
file2
我试着像这样复制:
COPY files/* /files/
但是,所有文件都放在/ files /中,在Docker中有没有办法保留子目录结构,以及将文件复制到它们的目录中?
发布于 2015-05-14 00:08:07
使用以下Dockerfile从副本中删除star:
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
发布于 2018-11-29 20:25:03
或者,您可以使用".“包含文件夹和子文件夹,而不是*,因为这将获取工作目录中的所有文件:
FROM ubuntu
COPY . /
RUN ls -la /
发布于 2020-10-29 11:51:44
如果您想完全复制具有相同目录结构的源目录,则不要使用星号(*)。在Dockerfile中写入COPY命令,如下所示。
COPY . destinatio-directory/
https://stackoverflow.com/questions/30215830
复制相似问题