波浪号扩展在 Docker COPY 命令中不起作用 [英] Tilde Expansion Doesn't Work in Docker COPY Command
问题描述
我有一个带有以下行的 Dockerfile:
复制 *.zip ~user1
用户 user1
已经存在并且有一个主目录(即 /home/user1
).当然,目标是将 zip 文件复制到该用户的主目录中,但是上面的结果是将 zip 文件复制到图像中字面上命名为 /~user1
的文件中.
以下内容按预期工作:
复制 *.zip/home/user1
这是 Docker 中的一个错误,还是存在我不知道的与波浪号扩展相关的限制?
在 Mac 上使用 Docker 1.13.0.
不支持 COPY
的波浪号扩展.
来自 复制文档:p><块引用>
dest
是绝对路径,或相对于 WORKDIR 的路径,源将在目标容器内复制到该路径中.
例子:
COPY test relativeDir/# 添加test"到`WORKDIR`/relativeDir/COPY test/absoluteDir/# 将test"添加到/absoluteDir/
I have a Dockerfile with the following line:
COPY *.zip ~user1
The user user1
already exists and has a home directory (i.e. /home/user1
). The goal, of course, is to copy the zip file into that user's home dir, however the result of the above is that the zip file is copied to a file named literally /~user1
in the image.
The following does work as expected:
COPY *.zip /home/user1
Is this a bug in Docker or is there a limitation related to tilde expansion that I'm not aware of?
Using Docker 1.13.0 on Mac.
Tilde expansion for COPY
is not supported.
From The COPY docs:
The
dest
is an absolute path, or a path relative to WORKDIR, into which the source will be copied inside the destination container.
Example:
COPY test relativeDir/ # adds "test" to `WORKDIR`/relativeDir/
COPY test /absoluteDir/ # adds "test" to /absoluteDir/
这篇关于波浪号扩展在 Docker COPY 命令中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!