Docker COPY from ubuntu absolute path

给你一囗甜甜゛ 提交于 2020-07-16 16:43:27

问题


I have following line in my dockerfile

COPY /root/url.net/volumes/persistent/url/root /usr/share/nginx/html

When I try to build the image with docker-compose I get

Service 'frontend' failed to build: lstat /root/url.net/volumes/persistent/url/root: no such file or directory

I can cd from anywhere to /root/url.net/volumes/persistent/url/root with no problem on my machine.

How can I specify the absolute path of the folder in the dockerfile?


回答1:


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.




回答2:


You can't. You have to copy/hardlink the files/folders inside the directory where you build the docker image.



来源:https://stackoverflow.com/questions/47012495/docker-copy-from-ubuntu-absolute-path

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