来自ubuntu绝对路径的Docker COPY [英] Docker COPY from ubuntu absolute path
问题描述
我在dockerfile中有以下一行
I have following line in my dockerfile
COPY /root/url.net/volumes/persistent/url/root /usr/share/nginx/html
当我尝试使用docker-compose构建映像时,得到
When I try to build the image with docker-compose I get
服务前端构建失败:lstat
/root/url.net/volumes/persistent/url/root:否这样的文件或
目录
Service 'frontend' failed to build: lstat /root/url.net/volumes/persistent/url/root: no such file or directory
我可以从任何地方cd到 /root/url.net/卷/永久/ URL /根
在我的机器上没有问题。
I can cd from anywhere to /root/url.net/volumes/persistent/url/root
with no problem on my machine.
如何在dockerfile中指定文件夹的绝对路径?
How can I specify the absolute path of the folder in the dockerfile?
推荐答案
资源的绝对路径是指构建上下文中的绝对路径,而不是主机上的绝对路径。因此,必须在构建映像之前将所有资源复制到运行docker build的目录中,然后在Dockerfile中提供这些资源的路径。 (这是指您运行Dockerfile的位置)
The absolute path of your resources refers to an absolute path within the build context, not an absolute path on the host. So all the resources must be copied into the directory where you run the docker build and then provide the path of those resources within your Dockerfiles before building the image. (This refers to the location where you run your Dockerfile)
有一个封闭的为此问题问题 。
There is a closed issue for this as well.
这篇关于来自ubuntu绝对路径的Docker COPY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!