Tilde Expansion Doesn't Work in Docker COPY Command

为君一笑 提交于 2019-12-09 03:06:38

问题


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.


回答1:


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/


来源:https://stackoverflow.com/questions/41927249/tilde-expansion-doesnt-work-in-docker-copy-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!