Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker permission error #193

Closed
clauded opened this issue Oct 13, 2017 · 4 comments
Closed

Docker permission error #193

clauded opened this issue Oct 13, 2017 · 4 comments

Comments

@clauded
Copy link

clauded commented Oct 13, 2017

I'm testing ocrmypdf on Ubuntu 17.10. Docker is installed as a snap. I run the following command:
docker run --rm -v "$(pwd):/home/docker" jbarlow83/ocrmypdf -l fra --pdf-renderer tesseract --output-type pdf test.pdf ocr.pdf

Then I get:
ERROR - Output file location (ocr.pdf) is not writable.

Now if I touch the file ocr.pdf and chmod 666 prior to lauching ocrmypdf, processing runs fine, the ocr.pdf file is created but I get the following error:

WARNING -    2: [tesseract] unsure about page orientation
WARNING -    2: [tesseract] lots of diacritics - possibly poor OCR
WARNING -    1: [tesseract] lots of diacritics - possibly poor OCR
  ERROR - Traceback (most recent call last):
  File "/appenv/lib/python3.5/site-packages/ruffus/task.py", line 751, in run_pooled_job_without_exceptions
    register_cleanup, touch_files_only)
  File "/appenv/lib/python3.5/site-packages/ruffus/task.py", line 567, in job_wrapper_io_files
    ret_val = user_defined_work_func(*params)
  File "/appenv/lib/python3.5/site-packages/ocrmypdf/pipeline.py", line 984, in copy_final
    shutil.copy(input_file, output_file)
  File "/usr/lib/python3.5/shutil.py", line 242, in copy
    copymode(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.5/shutil.py", line 144, in copymode
    chmod_func(dst, stat.S_IMODE(st.st_mode))
PermissionError: [Errno 1] Operation not permitted: 'ocr.pdf'
@jbarlow83
Copy link
Collaborator

jbarlow83 commented Oct 13, 2017

Since you're on Ubuntu why not just use the native version? apt-get install ocrmypdf

The general problem is that the Docker container needs permission to access pwd, and the container might be running as a different user that does not have permission to access pwd.

To work around the Docker permission issues you could pipe the file through the Docker container instead:

$ docker run --rm -i jbarlow83/ocrmypdf -l fra --pdf-renderer tesseract --output-type pdf - - < input.pdf > output.pdf

(The -i is required to allocate a terminal to docker.)

@clauded
Copy link
Author

clauded commented Oct 13, 2017

Since you're on Ubuntu why not just use the native version?

Distribution versions are generally behind the latest (Docker) version. There are also other very good reasons to use Docker...

To work around the Docker permission issues you could pipe the file through the Docker container instead

This works great (minus the missing j before barlow83/ocrmypdf in your example). Many Thanks!

@clauded clauded closed this as completed Oct 13, 2017
@geimist
Copy link

geimist commented Jan 8, 2019

It works here also fine - thanks.

But my Question: How can I grab the log of OCRmyPDF?

This don't work:
dockerlog=$( /usr/local/bin/docker run --rm -i $dockercontainer $ocropt - - < "$input" > "$output" | tee 2>&1 )

All OCRmyPDF logs are output in the terminal, even if I redirect them explicitly to a file
sh ./ocrmypdfscript.sh >> logfile.log 2>&1

@jbarlow83
Copy link
Collaborator

I think this answers the shell redirection question:
https://stackoverflow.com/a/50161815/369072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants