Description
No issue here. I just wanted to share my solution for using a docker container for building (maybe also an alternative to #119 ). This is especially useful if you for example don't want to install the huge texlive package on your computer. Another side effect is that on Windows the build process within a linux container is faster than building on the local system.
I just wrote myself a little script latexdocker.cmd
for running the container. It should work for both Linux and Windows and just executes all arguments inside the container:
:; echo "Running on *nix"; docker run -i --rm -w /data -v "$(pwd):/data" tianon/latex $*; exit $?
@ECHO OFF
ECHO Running on Windows
docker run -i --rm -w /data -v "%cd%:/data" tianon/latex %*
I am using the tianon/latex
image here, which is debian:jessie
with texlive-full
, biber
, latexmk
and make
(Dockerfile). Compressed image is only 1GB!
In the settings of LaTex-Workshop you can just use the script and pass the binary and other arguments to it:
"latex-workshop.latex.toolchain": [
{
"command": "latexdocker.cmd",
"args": [
"latexmk",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOCFILE%"
]
}
]
Of course you can also use the other binaries like pdflatex
and so on. Note that you can't use the %DOC%
variable in the settings as it contains the path on the local machine instead of the one in the container.
Activity
[-]Using docker for building[/-][+]Using docker for building documents[/+]James-Yu commentedon Nov 12, 2017
Thanks a lot for the description. Do you mind my incorporating the content into readme with credits?
lippertmarkus commentedon Nov 12, 2017
@James-Yu Go ahead! :) As I currently don't have the option: maybe someone should test if the
latexdocker.cmd
script is also working on Mac and Linux machines.tam3r commentedon Nov 26, 2017
Tried your script on a Mac.
That does not work:
:; echo "Running on *nix"; docker run -i --rm -w /data -v "$(pwd):/data" tianon/latex "$*"; exit $?
That works:
:; echo "Running on *nix"; docker run -i --rm -w /data -v "$(pwd):/data" tianon/latex $*; exit $?
lippertmarkus commentedon Nov 26, 2017
@tam3r Thanks for testing, I edited the script in #302 (comment)
lippertmarkus commentedon Feb 12, 2018
With newest edge build for Docker on Windows you can run LCOW aside of Windows containers. This requires to specify
--platform linux
when running linux containers in Windows-Container mode. The script should then look like:koppor commentedon Mar 28, 2018
Note that tianon/latex uses
texlive
from Debian, which is a bit outdated. Currently, in debian/strech, it is texlive 2016. Currently, texlive 2017 is frozen and texlive 2018 is short before a release.This might be not bad in general, but in case you a) want to have new packages (such as support for plantuml) or b) get the latest package updates, a newer version is beneficial.
In my image koppor/texlive, I am using TeX Live 2017 with the latest package updates and working setups for additional packages such as minted.
shinokada commentedon Oct 13, 2020
@koppor
I added
"latex-workshop.docker.image.latex":"koppor/texlive"
to setings.json, but it didn't work on my Mac.koppor commentedon Oct 13, 2020
Please try with danteev/texlive ( https://github.com/dante-ev/docker-texlive )
Yes, I should take down the Docker repository. The homepage redirects to the DANTE e.V. page, doesn't it?
shinokada commentedon Oct 13, 2020
@koppor Thanks. It works but it shows "Formatting failed. Please refer to LaTeX Workshop Output for details."
koppor commentedon Oct 13, 2020
Is there some possibility that you can check the "LaTeX Workshop Output" for details?