In this blog posting I show you how to use Overleaf Community Edition and store the resulting container on on self-hosted gitlab.
I used to use Bangors Overleaf to write my Masters thesis, but Bournemouth (as of March 2025) didnt have a overleaf server available. I found quickly that the free overleaf server online gives a limited amount of compile time and I also wanted to secure my own backups. With that I decided to self-host an overleaf server in the testlab.
Having recently migrated my test Active Directory servers to proxmox, I had two spare physical servers. The latest version of Overleaf uses a mongodb version (6.0) that requires virtualization (VXd) from the CPU, so it was a good idea in terms of both systems management (backups/load) to use a dedicated host as well. Previous versions of mongodb can be swapped out, but I didnt have a specific need to do so in this case.
I installed Ubuntu 22.04 and Docker 28.0.1 – there was nothing particularly different in the standard install processes to complete this.
I then started to following this good tutorial from Vultr which got me off the ground, however I soon started running into issues as I wanted various templates and fonts available, and the packages where either not found or the fonts unavailable.
The issue came because the Docker image doesnt include the necssary fonts. These cant be added to the running container as overleaf needs to be restarted and the fonts are not picked up correctly, therefore they must be built into the Dockerfile. I modified the provided Docker file (opt/overleaf/lib/Dockerfile)
FROM sharelatex/sharelatex:5.3.1
# Install required packages
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
texlive \
texlive-latex-extra \
texlive-fonts-recommended \
&& rm -rf /var/lib/apt/lists/*
When re-running the build scripts, the required fonts where then loaded onto the system. The docker image at this point is about 4.5G in size.
su - overleaf
cd $HOME # (should be /opt/overleaf)
bin/stop && bin/docker-compose rm -f sharelatex
bin/up -d --build
docker images # truncated for brevity
sharelatex/sharelatex 5.3.1 841a2e9c7e63 12 days ago 4.48GB
With the container now running with the required fonts, IEEE templates could be loaded directly into the document itself and rendered correctly.

However, the correct way to do this is to load the required packages into overleaf itself. This is done by spawning a root bash shell and loading the required packages in. This takes some time and its good to choose a local mirror to speed things up.
su - overleaf
cd /opt/overleafbin/shell # launches a docker shell
tlmgr update --selftlmgr option repository https://mirrors.mit.edu/CTAN/systems/texlive/tlnet/ # change repo as required from CTAN mirrors https://ctan.org/mirrors
nohup tlmgr install scheme-full & tail nohup.out # wait for updated
tlmgr update --self --all
exit
After sometime, the packages are now all installed and I can pretty much run any template/function I need, i.e. Gannt Charts, IEEE templates,etc.
\usepackage[a4paper, margin=0.8in]{geometry} % Adjust page size and margins
\usepackage{pgfgantt} % Gantt chart package
\usepackage{graphicx} % For figures if needed
\usepackage{lscape} % roate specific pages
\usepackage{pdflscape} % rotate specific pages (final PDF output)
\usepackage{afterpage}
%%%
\subsection{2025 - 2027}
\begin{center}
\begin{ganttchart}[
x unit=.06mm, % Reduce column width
y unit title=0.8cm,
y unit chart=0.8cm,
%vgrid, hgrid,
title label font=\bfseries,
time slot format=isodate
]{2025-01-01}{2027-12-31} % First 3 years
\gantttitlecalendar{year} \\
\ganttbar{Literature Review}{2025-01-01}{2027-12-31} \\
\ganttbar{Lab Setup}{2025-01-01}{2025-12-01} \\
\ganttbar{Quantum Algorithm Research}{2025-04-01}{2027-06-30} \\
\ganttbar{Simulation and Testing}{2027-07-01}{2027-12-31}
\end{ganttchart}
\end{center}

Whilst this allowed me to use the current running docker container, I wanted to ensure that I could use this container each time the server rebooted for patching/operations as well be able to storage the package in selfhost gitlab which uses letsencrypt certs on nginx for its secure connections.
First I wrote out the update docker container, note this is whilst it is still running – i have just exited out of the root shell to get back to the OS.
docker commit sharelatex sharelatex/sharelatex:with-texlive-full
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
sharelatex/sharelatex with-texlive-full 527025329b2f 12 days ago 8.57GB
sharelatex/sharelatex 5.3.1 841a2e9c7e63 12 days ago 4.48GB
Modify the Overleaf config to use the updated image
vi /opt/overleaf/lib/docker-compose.override.yml
---
version: '2.2'
services:
sharelatex:
image: sharelatex/sharelatex:with-texlive-full
Now that I have a fully working container I want to push it to Gitlab’s container registry. As docker wont ‘trust’ lets-encrypt certs and they are renewed every 3 months, I allowed the repo in the ‘insecure-registries
‘ by modifying the docker config on the overleaf server to allow it. This assumes that DNS/Host resolution is setup correctly, change the name and port accordingly.
cat /etc/docker/daemon.json
{
"insecure-registries": ["alan-3209ay1.alanknipmeyer.science","alan-3209ay1:5050","alan-3209ay1.alanknipmeyer.science:5050"],
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
I then generated an token so I could authenticate docker using it, these are located within user settings reached via your icon and preferences, then access tokens.
I then was able to login to my own gitlab ready to push the image.
docker login alan-3209ay1:5050
Username: alan
i Info → A Personal Access Token (PAT) can be used instead.
To create a PAT, visit https://app.docker.com/settings
Password: <paste token>
WARNING! Your credentials are stored unencrypted in '/root/.docker/config.json'.
Configure a credential helper to remove this warning. See
https://docs.docker.com/go/credential-store/
Login Succeeded
As the message says, its better to use a credentail helper but for brevity of this post the link is included here.
Next it was time to tag the image so it can be pushed to the repo.
docker tag 527025329b2f alan-3209ay1:5050/knipmeyer-it/overleaf
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
sharelatex/sharelatex with-texlive-full 527025329b2f 12 ago 8.57GB
docker push alan-3209ay1:5050/knipmeyer-it/overleaf
Using default tag: latest
The push refers to repository [alan-3209ay1:5050/knipmeyer-it/overleaf]
a714a521a8ca: Pushing [==================================================>] 4.241GB
..
latest: digest: sha256:896e7e0d322af9cc480058ca102b34f768c153d22cb080b5da8288ba00241f34 size: 9697
I then confirmed the digest file was the same in gitlab.

With automated backups of gitlab already in place and the modify build code pushed along with the container, I’m now able to build and run my own overleaf server with no compile time restrictions.
Hope this helps and thanks for following the blog!