Installing ConTeXt LMTX into a Docker container

Unofficial ConTeXt Wiki mirror

Last modified: 2025-01-18

1) Install Docker

Install Docker for your system by following the instructions at Docker.com.

2) Build the Docker container

Building a container is a two-step process: first create a Dockerfile that specifies what needs to be built, then build it.

A Dockerfile is a plain text file called Dockerfile without any filetype extension. Copy the following into your Dockerfile:

# ConTeXt LMTX in a container
FROM debian:latest
WORKDIR /opt/context

# The official Debian image provided by Docker does not include a program that can
# uncompress .zip files, so we have to install one.
RUN apt-get -y update \
    && apt-get -y autoremove \
    && apt-get clean \
    && apt-get install -y unzip \
    && rm -rf /var/lib/apt/lists/*

# Use the 64 bit Linux version
ADD https://lmtx.pragma-ade.com/install-lmtx/context-linux-64.zip context-linux-64.zip
RUN unzip context-linux-64.zip \
    && rm installation.pdf context-linux-64.zip

# Run the ConTeXt installer
RUN chmod 755 install.sh \
    && (./install.sh > install.log 2>&1)

# Switch to a working directory
WORKDIR /home/context
ENV PATH=/opt/context/tex/texmf-linux-64/bin:$PATH

and then run these commands:

$ cd <the directory containing Dockerfile>
$ docker build -t context .

(Note the full stop at the end.)

3) Check that ConTeXt built correctly (optional)

You can run a bash shell within the container to check that ConTeXt built correctly.

$ cd <the directory containing Dockerfile>
$ docker run -it context bash

First, check that ConTeXt runs:

# context --version

which should give something like:

root@f96c7ca62c48:/home/context# context --version
mtx-context     | ConTeXt Process Management 1.06
mtx-context     |
mtx-context     | main context file: /opt/context/tex/texmf-context/tex/context/base/mkiv/context.mkiv
mtx-context     | current version: 2024.08.16 16:30
mtx-context     | main context file: /opt/context/tex/texmf-context/tex/context/base/mkxl/context.mkxl
mtx-context     | current version: 2024.08.16 16:30

If not then check the build log for errors:

# more /opt/context/install.log

Type exit to end.

4) Compile your ConTeXt document

This is very similar to the check in step 3 but with a "bind mount" added so that Docker can access your source files.

$ cd <the directory containing your ConTeXt source(s)>

Create a file hello.tex containing the lines:

\starttext
Hello, this is \CONTEXT\ running in Docker
\stoptext

and then generate a PDF from it using:

$ docker run -itv .:/home/context context bash
# context hello.tex

If it all works correctly you should have a hello.pdf file in your source(s) directory.