1

Is it possible to pull texlive image in docker (e.g. https://hub.docker.com/r/texlive/texlive) and use it from my computer instead of installing texlive on my computer?

I like the idea using containers instead of installing software.

  • (IMHO running `brew install texlive` once and then running `latex some-file` directly is much better than the long-winded `docker run` command you've gotten as a correct answer.) – David Maze Oct 19 '22 at 09:58

2 Answers2

1

This should work something like

sudo docker run -i --rm --name latex -v "$PWD":/usr/src/app -w /usr/src/app registry.gitlab.com/islandoftex/images/texlive:latest pdflatex essay.tex

Taken from https://nico.dorfbrunnen.eu/de/posts/2020/docker-latex/ (german)

Check wiki page for docker images: https://gitlab.com/islandoftex/images/texlive/-/wikis/home

Slava Kuravsky
  • 2,702
  • 10
  • 16
0

LaTeX's full distribution is too large. I recommend using TinyTeX and then add packages as needed. This should work:

apt-get update
apt-get install perl wget -y  
wget -qO- "https://yihui.org/tinytex/install-bin-unix.sh" | sh 
export PATH="$PATH:/root/.TinyTeX/bin/x86_64-linux"

From here, run bash in your container, compile your latex file, and check what packages are missing. For example, you may get a message such as ! LaTeX Error: File `type1cm.sty' not found. In this case, from inside a container run tlmgr search --global --file "type1cm.sty" which will output something like this:

tlmgr: package repository https://ctan.mirror.garr.it/mirrors/ctan/systems/texlive/tlnet (not verified: gpg unavailable)
type1cm:
    texmf-dist/tex/latex/type1cm/type1cm.sty

then, run

tlmgr install type1cm

Repeat this process until you have all the packages you need. In my case also needed to add dvipng, required by Python’s matplotlib package:

apt-get install dvipng -y

(for some reason I needed to install it after TinyTeX).

The equivalent in a Dockerfile would be the following:

RUN apt-get update
RUN apt-get install perl wget -y  

# fetch TinyTeX installer and run it
RUN wget -qO- "https://yihui.org/tinytex/install-bin-unix.sh" | sh 

# add TinyTeX to PATH variable
ENV PATH="$PATH:/root/.TinyTeX/bin/x86_64-linux"

# add needed packages and dvipng:
RUN tlmgr install type1cm
RUN apt-get install dvipng


andrea m.
  • 668
  • 7
  • 15