如何使用 Docker 文件将一层中的多个文件复制到不同位置?
How to copy multiple files in one layer using a Docker file to different locations?
是否可以将多个文件复制到 Dockerfile
中的不同位置?
我想从:
COPY outputs/output/build/.tools /root/.tools
COPY outputs/output/build/configuration /root/configuration
COPY outputs/output/build/database/postgres /root/database/postgres
我尝试了以下方法,但没有成功:
COPY ["outputs/output/build/.tools /root/.tools","outputs/output/build/configuration /root/configuration","outputs/output/build/database/postgres /root/database/postgres"]
不确定这是否可能。
在您的 docker
构建上下文目录中创建一个文件 .dockerignore
。为要复制的根目录创建软 link (ln
),并在 .dockerignore
.
中排除不需要的目录
在您的情况下,您不需要软 link,因为该目录已经在 docker
构建上下文中。现在,在 .dockerignore
文件中添加您不需要的目录,例如。如果你不想要 bin
目录,你可以这样做,
# this is .dockerignore file
outputs/output/build/bin*
终于在你的 Dockerfile
,
COPY outputs/output/build/ /root/
详情为here。
您似乎正在尝试进行 bash 样式 []
大括号扩展
RUN
命令使用 sh
而不是 bash
查看这篇讨论它的 SO 文章
或docker参考
是否可以将多个文件复制到 Dockerfile
中的不同位置?
我想从:
COPY outputs/output/build/.tools /root/.tools
COPY outputs/output/build/configuration /root/configuration
COPY outputs/output/build/database/postgres /root/database/postgres
我尝试了以下方法,但没有成功:
COPY ["outputs/output/build/.tools /root/.tools","outputs/output/build/configuration /root/configuration","outputs/output/build/database/postgres /root/database/postgres"]
不确定这是否可能。
在您的 docker
构建上下文目录中创建一个文件 .dockerignore
。为要复制的根目录创建软 link (ln
),并在 .dockerignore
.
在您的情况下,您不需要软 link,因为该目录已经在 docker
构建上下文中。现在,在 .dockerignore
文件中添加您不需要的目录,例如。如果你不想要 bin
目录,你可以这样做,
# this is .dockerignore file
outputs/output/build/bin*
终于在你的 Dockerfile
,
COPY outputs/output/build/ /root/
详情为here。
您似乎正在尝试进行 bash 样式 []
大括号扩展
RUN
命令使用 sh
而不是 bash
查看这篇讨论它的 SO 文章
或docker参考