0

I am using python SDK package to run docker from python. Here is the docker command I tried to run using python package:

docker run -v /c/Users/msagovac/pdf_ocr:/home/docker jbarlow83/ocrmypdf-polyglot --skip-text 0ce9d58432bf41174dde7148486854e2.pdf output.pdf

Here is a python code:

import docker
client = docker.from_env()
client.containers.run('jbarlow83/ocrmypdf-polyglot', '--skip-text "0ce9d58432bf41174dde7148486854e2.pdf" "output.pdf"', "-v /c/Users/msagovac/pdf_ocr:/home/docker")

Error says file ot found. I am not sure where to set run options:

-v /c/Users/msagovac/pdf_ocr:/home/docker
Mislav
  • 1,533
  • 16
  • 37

1 Answers1

2

Try with named parameters:

client.containers.run(
           image='jbarlow83/ocrmypdf-polyglot', 
           command='--skip-text "0ce9d58432bf41174dde7148486854e2.pdf" "output.pdf"',
           volumes={'/c/Users/msagovac/pdf_ocr': {'bind': '/home/docker', 'mode': 'rw'}},
          )

Also it seems that the path of the volume to mount is incorrect, try with C:/Users/msagovac/pdf_ocr

Roomm
  • 905
  • 11
  • 23
  • I works. How to include `-v ` option after `docker run`? – Mislav Oct 25 '18 at 10:56
  • After run? I think you can mount a volume to container after it started running https://stackoverflow.com/questions/28302178/how-can-i-add-a-volume-to-an-existing-docker-container – Roomm Oct 25 '18 at 10:58
  • the -v option is the parameter `volumes` – Roomm Oct 25 '18 at 11:48