Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker COPY from ubuntu absolute path

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?

like image 305
isADon Avatar asked Oct 30 '17 10:10

isADon


People also ask

Does Docker Copy command Create directory?

Docker Dockerfiles COPY InstructionAll new files and directories are created with a UID and GID of 0.

Is Docker a recursive COPY?

The cp command behaves like the Unix cp -a command in that directories are copied recursively with permissions preserved if possible. Ownership is set to the user and primary group at the destination. For example, files copied to a container are created with UID:GID of the root user.


1 Answers

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.

like image 76
Ravindu Nirmal Fernando Avatar answered Oct 05 '22 08:10

Ravindu Nirmal Fernando