John Davidson

php - "no such file or directory" when passing full path to Docker image, but works with relative path to same folder

0 comments
Message:


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



My Answer:
PHP is a server-side scripting language that is commonly used for web development. It can be embedded into HTML code and is often used to create dynamic web pages. PHP stands for Hypertext Preprocessor.

Rate this post

3 of 5 based on 8214 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us