首页 > 解决方案 > Docker + ImageMagick:无法直接在已安装的驱动器上处理文件

问题描述

我已经从 ubuntu:18.04创建了一个 docker 映像,并且我已经安装了ImageMagick。该程序只能转换 docker 存储上的文件,我不知道为什么(我在 windows 上)。

我做了以下事情:

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

但是,如果我将文件复制到 docker 映像,一切运行正常:

# 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

有什么办法可以避免来回复制数据?您对我为什么会收到这些错误有任何建议吗?

标签: dockerimagemagickstoragemount

解决方案


推荐阅读