Building a LaTeX Docker image

My local Tex Live version is a bit outdated and I do not want my Debian Jessie to force an update to the sid distribution. This is maybe a good point to start running the pdflatex command in a Docker container with a newer version.

Dockerfile

The following Dockerfile would install the package texlive-full in a Debian 9 container.

FROM debian:9

RUN apt-get update \
    && apt-get install -y \
    texlive-full \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

LaTeX with increased main memory

But I would like to increase the main memory as described here. That can be achieved with the following Dockerfile.

FROM debian:9

RUN apt-get update \
    && apt-get install -y \
    texlive-full \
    && echo "\nmain_memory = 12000000" >> /etc/texmf/texmf.d/00debian.cnf \
    && echo "\nextra_mem_bot = 12000000" >> /etc/texmf/texmf.d/00debian.cnf \
    && echo "\nfont_mem_size = 12000000" >> /etc/texmf/texmf.d/00debian.cnf \
    && echo "\npool_size = 12000000" >> /etc/texmf/texmf.d/00debian.cnf \
    && echo "\nbuf_size = 12000000" >> /etc/texmf/texmf.d/00debian.cnf \
    && update-texmf \
    && texhash \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

Build LaTeX Docker image

The image can be build with the following command executed in the directory of the Dockerfile.

docker build -t pdflatex .

Run LaTeX Docker container

Assumed that the main document.tex file exists in the current directory, the following command will execute the command pdflatex in the Docker container.

docker run --rm -v "$PWD":/usr/src/project -w /usr/src/project pdflatex pdflatex document.tex
Next Previous