[SOLVED] (Trial version) Run as non-root user inside Docker

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
ttomdewit
Newbie Member
Posts: 5
Joined: Thu Mar 18, 2021 12:34 pm

[SOLVED] (Trial version) Run as non-root user inside Docker

Post by ttomdewit » Thu Mar 18, 2021 12:44 pm

The answer can be found at https://qcad.org/rsforum/viewtopic.php? ... 553#p32554



Hi everyone,

Thank you for hosting this forum. I will try and describe my problem as best I can in the hopes someone has had a similar issue (and a solution).

QCAD version:

Code: Select all

./qcad -platform offscreen
QCAD version  3.26.1
Linux details:

Code: Select all

uname -m
x86_64
I can add more details when and if required.

I've downloaded the following file https://qcad.org/archives/qcad/qcadcam- ... x86_64.run from https://qcad.org/en/download

I use Docker to spin up (albeit temporary) servers. I use a PHP-CLI user (non-root) as default via docker-compose. The following command is used to execute commands inside Docker:

Code: Select all

docker-compose exec php-cli bash
After that I used chmod +x to make the .run-file executable and ran it successfully.

I've ran the following command as non-root user without it actually creating a PDF file:

Code: Select all

./dwg2pdf -a -c -k -f -platform offscreen /path/to/file.dwg
It runs the program but never stores the PDF file in /path/to/file.pdf. When I run the same command as root user it does create a PDF file.

How can I run the (trial) program to successfully create a PDF file as a non-root user?

Thank you for your time.


Tom de Wit
Last edited by ttomdewit on Thu Mar 18, 2021 1:10 pm, edited 3 times in total.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: (Trial version) Run as non-root user inside Docker

Post by andrew » Thu Mar 18, 2021 12:51 pm

You would have to make sure that said user has write access to the output directory.

Also, keep in mind that if you have previously created a file as root, that file might not be overwritable by a regular user.

ttomdewit
Newbie Member
Posts: 5
Joined: Thu Mar 18, 2021 12:34 pm

Re: (Trial version) Run as non-root user inside Docker

Post by ttomdewit » Thu Mar 18, 2021 12:54 pm

andrew wrote:
Thu Mar 18, 2021 12:51 pm
You would have to make sure that said user has write access to the output directory.

Also, keep in mind that if you have previously created a file as root, that file might not be overwritable by a regular user.
I'll try again and attempt to write to my own "home" directory. I'll report back.

ttomdewit
Newbie Member
Posts: 5
Joined: Thu Mar 18, 2021 12:34 pm

Re: (Trial version) Run as non-root user inside Docker

Post by ttomdewit » Thu Mar 18, 2021 1:09 pm

ttomdewit wrote:
Thu Mar 18, 2021 12:54 pm
andrew wrote:
Thu Mar 18, 2021 12:51 pm
You would have to make sure that said user has write access to the output directory.

Also, keep in mind that if you have previously created a file as root, that file might not be overwritable by a regular user.
I'll try again and attempt to write to my own "home" directory. I'll report back.
I'm happy to report this works. I was under the impression the tmp folder was mine. My mistake, entirely!

ttomdewit
Newbie Member
Posts: 5
Joined: Thu Mar 18, 2021 12:34 pm

Re: (Trial version) Run as non-root user inside Docker

Post by ttomdewit » Wed Mar 24, 2021 1:19 pm

andrew wrote:
Thu Mar 18, 2021 12:51 pm
You would have to make sure that said user has write access to the output directory.

Also, keep in mind that if you have previously created a file as root, that file might not be overwritable by a regular user.
Hi Andrew, could you please verify the following with me?

Why would the following code work:

Code: Select all

dwg2pdf -platform offscreen -a -c -f -k storage/framework/testing/disks/local/test.dwg
But not this:

Code: Select all

dwg2pdf -platform offscreen -a -c -f -k storage/framework/testing/disks/local/test.dwg -o storage/framework/testing/disks/local/test.pdf
I can guarantee that the PDF file is, in fact, generated with the first example command but the error that's generated in the second command is:

Code: Select all

Cannot import file: /var/www/html/storage/framework/testing/disks/local/test.pdf
The response on the first example is:

Code: Select all

Converting
from: /var/www/html/storage/framework/testing/disks/local/test.dwg
to  : /var/www/html/storage/framework/testing/disks/local/test.pdf

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: [SOLVED] (Trial version) Run as non-root user inside Docker

Post by andrew » Wed Mar 24, 2021 1:24 pm

The last parameter is always the input file. So:

Code: Select all

dwg2pdf -platform offscreen -a -c -f -k -o storage/framework/testing/disks/local/test.pdf storage/framework/testing/disks/local/test.dwg

ttomdewit
Newbie Member
Posts: 5
Joined: Thu Mar 18, 2021 12:34 pm

Re: [SOLVED] (Trial version) Run as non-root user inside Docker

Post by ttomdewit » Wed Mar 24, 2021 1:27 pm

andrew wrote:
Wed Mar 24, 2021 1:24 pm
The last parameter is always the input file. So:

Code: Select all

dwg2pdf -platform offscreen -a -c -f -k -o storage/framework/testing/disks/local/test.pdf storage/framework/testing/disks/local/test.dwg
It's right there in the description.......

Code: Select all

Usage: ./dwg2pdf [OPTIONS]... <drawing file>
from https://www.qcad.org/en/qcad-command-line-tools#dwg2pdf

Thanks, it seems to work as intended now.

Post Reply

Return to “QCAD 'How Do I' Questions”