0

I have created a docker image FROM ubuntu:18.04 and I have installed ImageMagick. The program can only convert files on the docker storage, and I am not sure why (I am on windows).

I have done the following:

# Running container
docker run -it -v c:/path/to/files:/data/ myimage

# Running imagemagick on files in data
magick -density 300 /data/myinput.pdf -quality 300 /data/myoutput.png

# Error message
Error: /undefinedfilename in (/tmp/magick-86JJbaxmanPmtT)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push
Dictionary stack:
   --dict:965/1684(ro)(G)--   --dict:0/20(G)--   --dict:78/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.26: Unrecoverable error, exit code 1
magick: FailedToExecuteCommand `'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r300x300'  '-sOutputFile=/tmp/magick-86AnWywQtp36Zc%d' '-f/tmp/magick-86UR2ooTLLxHe3' '-f/tmp/magick-86JJbaxmanPmtT'' (1) @ error/pdf.c/InvokePDFDelegate/290.

However, if I copy the file to the docker image everything runs fine:

# Copying file to docker
mkdir data2
cp /data/myinput.pdf /data2/myinput.pdf

# Running imagemagick on file in data2
magick -density 300 /data2/myinput.pdf -quality 300 /data2/myoutput.png

Is there any way to avoid having to copy the data back and forth? Do you have any suggestions to why I am getting these errors?

Esben Eickhardt
  • 3,183
  • 2
  • 35
  • 56
  • Likely an autorization problem on the volume. Numeric ids in the container and the host should match (thouhg I don't know how that translated in a Windows host). Run an interactive shell in the container (`docker exec -it {container} bash`) and explore (`ls`/`touch`...). – xenoid Mar 06 '19 at 09:57
  • Thanks for the suggestion. I already checked the permissions and I have also created new files using touch, but it does not seem to work. – Esben Eickhardt Mar 06 '19 at 10:04
  • Run the command with a -debug option, perhaps? And shouldn't that be `magick convert` instead of just `magick`? – xenoid Mar 06 '19 at 10:08
  • I'd just use ImageMagick [native Windows binaries](https://imagemagick.org/script/download.php#windows) and not bother with Docker here. – David Maze Mar 06 '19 at 10:26
  • I need docker for putting the tool into production – Esben Eickhardt Mar 06 '19 at 12:21
  • I do not know Docker or Windows. But does the Docker system's policy.xml file give you permission to read PDF files? See https://stackoverflow.com/questions/52861946/imagemagick-not-authorized-to-convert-pdf-to-an-image/52863413#52863413. Also you have a space after the data/ before myimage. Perhaps you should quote the whole path or remove the space. Also on Windows, don't you need to use \ rather than / – fmw42 Mar 06 '19 at 17:12
  • I do not think it has anything to do with policies as with will process the pdf-files when they are on the docker storage, but not when on the mounted storage. – Esben Eickhardt Mar 08 '19 at 12:25

0 Answers0