The easiest way to use this container is to mount a volume into the container and run pandoc afterwards:
docker run --rm -v $(pwd):/home/pandoc knsit/pandoc:latest pandoc my-markdown.md -o my-pdf.pdf
Or to convert multiple files at once you could run a script like that:
docker run --rm -v $(pwd):/home/pandoc knsit/pandoc:latest /bin/sh build-pdfs.sh
where the build-pdfs.sh
could look like this
#!/bin/sh
[ -d pdf_out ] || mkdir pdf_out
find . -name "*.md" -type f | while IFS='' read -r PATHNAME; do
OUTFILE="${PATHNAME/.md/.pdf}"
pandoc $PATHNAME --pdf-engine=pdflatex -o pdf_out/$OUTFILE
done
to convert all markdown files in the current folder to PDF files.
You may also use it interactive:
docker run --rm -ti -v $(pwd):/home/pandoc knsit/pandoc:latest
The container does not expose any container but the working directory is /home/pandoc
and it's good practice to mount your local directory to this directory (as shown above).
The Powershell equivalent to the bash script above could look like this:
docker run -v "$((pwd).Path):/home/pandoc" --rm knsit/pandoc ./buildPDFs.sh
Remark: you might get an error like
standard_init_linux.go:185: exec user process caused "no such file or directory"
this might be caused by the line endings differences of Windows (CRLF) and Linux (LF). You can check if your line endings are fine e.g. with Notepad++.
Of course it's also possible to convert just a single file:
docker run -v "$((pwd).Path):/home/pandoc" --rm knsit/pandoc pandoc -o myDocument.pdf my-markdown-file.md