3

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".

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Ora nge
  • 193

1 Answers1

2

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/:

  1. 755
  2. -rf
  3. roundcubemail-1.2.3

To solve this particular issue, I would recommend adding this to your Dockerfile:

RUN mkdir -p /var/www/html
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255