"Cannot create directory ... no such file or directory"
cp
will report that error if the parent directory (www
in this case) does not exist:
$ mkdir src dest
$ touch src/file
$ cp -r src dest/www/html/
cp: cannot create directory ‘dest/www/html/’: No such file or directory
as opposed to:
$ mkdir -p dest/www/html
$ cp -r src dest/www/html/
$ find dest
dest
dest/www
dest/www/html
dest/www/html/src
dest/www/html/src/file
Also, I believe your:
RUN cp 775 -rf roundcubemail-1.2.3/. /var/www/html/
command is potentially a reference to the install -m
command, which accepts a MODE
to set on copied files. cp
, on the other hand, is simply expecting a list of source directories, and so that command is looking for three files/directories to copy to /var/www/html/
:
755
-rf
roundcubemail-1.2.3
To solve this particular issue, I would recommend adding this to your Dockerfile:
RUN mkdir -p /var/www/html
Related videos on Youtube
![Ora nge](https://lh4.googleusercontent.com/-Fs8kARaH79s/AAAAAAAAAAI/AAAAAAAAAJI/CICN10lagHc/photo.jpg?sz=256)
Comments
-
Ora nge almost 2 years
When executing the dockerfile, the command
RUN cp -rf roundcubemail-1.2.3/. /var/www/html/
is executed and I'm getting the following error:cp: cannot create directory '/var/www/html/': No such file or directory ERROR: Service 'mailserver' failed to build: The command '/bin/sh -c cp -rf roundcubemail-1.2.3/. /var/www/html/' returned a non-zero code: 1
That error occurs when executing any command on that directory. I already changed the permissions to 775, but that didn't change anything.
When adding 775 to
RUN cp 775 -rf roundcubemail-1.2.3/. /var/www/html/
the error changes to "is not a directory".-
JShorthouse about 5 yearsI assume this is a Docker question? If it is, can you specify that in your question and post your Dockerfile?
-
roaima about 5 years
/var/www/html
exists and is a directory? -
Kusalananda about 5 yearsThe commands are run using
sh -c
, which means the command possibly has to be quoted. -
Ora nge about 5 years@roaima Yes i checked it with [ -d "/path/to/dir" ]
-
Jeff Schaller about 5 yearsinside the container, though?
cp
will report that error if the/var/www
does not exist -
Ora nge about 5 years@JeffSchaller How to chek if it's inside the container?
-
roaima about 5 yearsActually, given the
cp
command, just/var/www
needs to exist (as a directory). It'll createhtml
if necessary, but not complain if it already exists. -
Ora nge about 5 years@roaima So any idea how to solve that?
-
-
Ora nge about 5 yearswhat are src and dest for?
-
Jeff Schaller about 5 yearsI didn't feel like clobbering my existing /var/www/html directory to test, so those are just example directories to demonstrate the behavior (and the solution).
-
roaima about 5 yearsIn your example, if you change the source from
src
tosrc/.
it will either use the existing target or create it. See How to copy a folder recursively in an idempotent way using cp. -
Ora nge about 5 yearsSo I need to add a ' RUN mkdir -p var/www/html RUN cp -r src/ var/www/html/ ' in front of the other commands?
-
Ora nge about 5 yearsAlright, thank you. I'll test this tomorrow. :)