来自 ubuntu 绝对路径的 Docker COPY [英] Docker COPY from ubuntu absolute path

查看:27
本文介绍了来自 ubuntu 绝对路径的 Docker COPY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 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/volumes/persistent/url/root 在我的机器上没有问题.

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 的目录中,然后在构建映像之前在 Dockerfiles 中提供这些资源的路径.(这是指您运行 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)

也有一个封闭的 issue.

There is a closed issue for this as well.

这篇关于来自 ubuntu 绝对路径的 Docker COPY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆