php - "no such file or directory" when passing full path to Docker image, but works with relative path to same folderGet the solution ↓↓↓
From a PHP page in Apache I'm trying to run a docker command that will generate a PDF. I've added both my user and the www-data user to the docker group so they can execute a docker command without sudo.
This works within a PHP file that exists at the /home/my_user/projects/my_project/public folder:
system("docker run --rm -v `pwd`:/app -w /app weasyprint:51 ./healthcheck.htm /weasyprint_test.pdf");
But when I specify the full path (which I've verified is correct), it doesn't work:
system("docker run --rm -v `pwd`:/app -w /app weasyprint:51 /home/my_user/projects/my_project/public/healthcheck.htm /home/my_user/projects/my_project/public/weasyprint_test.pdf");
I see this in the PHP error log when I run the second version: su-exec: /home/my_user/projects/my_project/public/healthcheck.htm: No such file or directory
For the life of me, I can't figure out why the first version would work and the second wouldn't because they are referring to the same path, just via different syntax. Please let me know if you have any ideas.
If it helps, I'm using the this Docker image for Weasyprint: https://hub.docker.com/r/minidocks/weasyprint
On the Docker VM run
ls /home/ and I would wager the directory you expect isn't there. The user referenced in your path probably doesn't exist on the VM, only on your host machine.
The relative path works because it's relative to the root directory provided.
Share solution ↓
Link To Answer People are also looking for solutions of the problem: script cache:clear returned with error code 255
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.