Tutorial: TeXstudio inside Docker container
 
Motivation
- Overleaf’s compilation time is too slow. I switched to TeXLive+TeXstudio and loved it
- On installing texlive-fonts-extra, I was afflicted by fonts conflict withfonts-font-awesomethat render the cool icons on my i3 taskbar
- Asked it on AskUbuntu. I was able to solve it, albeit unsatisfactorily, and answered it too
- Font Awesome icons in the text editor were still messed up. Enter, Docker
Steps
- Install Docker
- mkdir ~/texstudio-docker && cd ~/texstudio-docker
- touch Dockerfile
- touch start_texstudio.sh
- chmod +x start_texstudio.sh
- Populate the two created files (code given below)
- ./start_texstudio.sh
- TeXstudio’s GUI should appear if all went well
Dockerfile
FROM ubuntu:focal
# setup timezone
RUN echo 'Etc/UTC' > /etc/timezone && \
    ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
    apt-get update && \
    apt-get install -q -y --no-install-recommends tzdata && \
    rm -rf /var/lib/apt/lists/*
# install packages
RUN apt-get update \
    && apt-get install -y texlive-latex-extra texlive-fonts-extra texstudio cm-super \
    && apt-get clean
RUN apt-get install -y sudo \
    && apt-get clean
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
    mkdir -p /home/developer && \
    echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
    echo "developer:x:${uid}:" >> /etc/group && \
    echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
    chmod 0440 /etc/sudoers.d/developer && \
    chown ${uid}:${gid} -R /home/developer && mkdir -p /home/developer/workspace
USER developer
ENV HOME /home/developer
WORKDIR /home/developer/workspace
start_texstudio.sh
#!/bin/sh
docker build -t tex_image .
docker run -it \
  --rm \
  -v $PWD:/home/developer/workspace \
  -v /tmp/.X11-unix/:/tmp/.X11-unix \
  -e DISPLAY=$DISPLAY \
  tex_image texstudio
How to use
- Copy directories containing TeX scripts into ~/texstudio-docker. These can now be found from within TeXstudio’s GUI
- The next time you want to open TeXstudio, cd ~/texstudio-docker && ./start_texstudio.sh
- If you require additional packages for TeXLive, add it to the Dockerfile and run the shell script again
