Self-hosting Overleaf Community Edition with Docker: Detailed Guide
Introduction
Overleaf Community Edition (CE) is an open-source version that allows you to self-host Overleaf on your own server, suitable when:
- You want full control over LaTeX data.
- Need deployment in an internal network (university / lab / company).
- Don't want to depend entirely on overleaf.com.
In this article, we will deploy Overleaf CE using Overleaf Toolkit and Docker, install full TeX Live, and save the customized image.
System Requirements
Before starting, ensure your machine meets the following requirements:
- Docker: Version 20.10 or later
- Docker Compose: Version 2.0 or later
- RAM: Minimum 4GB (8GB recommended)
- Disk Space: Minimum 10GB free
- OS: Linux, macOS, or Windows with WSL2
Installing Overleaf Toolkit
Step 1: Clone repository
git clone https://github.com/overleaf/toolkit.git
cd toolkit
Step 2: Configure environment
Create environment configuration file:
bin/init
This command will automatically create configuration files in the config/ directory.
Edit config/overleaf.rc with necessary information:
# Admin email address
SHARELATEX_ADMIN_EMAIL=admin@example.com
# Admin password
SHARELATEX_ADMIN_PASSWORD=your_password
# Domain name (if any)
SHARELATEX_SITE_URL=http://localhost:5000
# To allow accessing Overleaf from other computers in LAN,
# edit the following line in `config/overleaf.rc`:
SHARELATEX_BIND_ADDRESS=0.0.0.0
# This helps Overleaf listen on all network addresses instead of just localhost.
Step 3: Start Overleaf
sudo bin/up -d
This command will:
- Download necessary Docker images
- Start services (ShareLaTeX, Redis, MongoDB)
- Set up database
- Start web server
Accessing Overleaf
After successful startup, you can access Overleaf at:
To configure account and password.
Installing Full TeX Package
Note: The self-hosted Overleaf version installed via the guide above is only a minimal version, it does not have full TeX packages like on overleaf.com!
- If you only compile basic LaTeX projects, that's enough.
- However, with complex templates, missing packages is normal. Then you will need to install more packages (see guide below).
To install full TeX Live (Full):
Enter docker shell:
sudo bin/shell
Download full Tex package:
tlgmr install schema-full
Basic commands with tlmgr
After entering Docker shell as guided above, you can use tlmgr to manage TeX packages:
- Update tlmgr and TeX packages:
tlmgr update --self --all - Install a specific package (e.g., xcolor):
tlmgr install xcolor - Search for packages related to a keyword (e.g., table):
tlmgr search --global --word table - View list of installed packages:
tlmgr list --only-installed - Remove a package:
tlmgr remove <package-name>
Note: When installing packages with
tlmgr, it only affects the Overleaf Docker container, not the host OS.
See more documentation: tlmgr - TeX Live Manager
This process can take a long time (~download + install > 5GB). But afterwards, you will have almost every package like the official Overleaf version.
To check if a package exists, on Overleaf go to "Logs and output files", see which package is missing error and install it!
Note: After installing full packages with
tlmgr, you should run the following command to update paths of binaries installed by TeX Live:tlmgr path add
After finishing in Docker shell, run this command to exit:
exit
Saving changes to a new Docker Image
By default, any changes you make in the container (e.g., installing more TeX packages via tlmgr) will be lost if you remove or recreate the container with Docker Compose.
To keep these changes (e.g., when installing full TeX Live), you need to commit the container into a new Docker Image.
Step 1: Check Overleaf version
Identify current version to tag the new image correctly:
cat config/version
Example output: 5.0.3
Step 2: Commit container to new Docker Image
Assume container name is sharelatex (you can check with docker ps).
Run the following command, replacing 5.0.3 with the correct version if different:
docker commit sharelatex sharelatex/sharelatex:5.0.3-with-texlive-full
This command creates a new image sharelatex/sharelatex:5.0.3-with-texlive-full containing all changes you made (e.g., installed full TeX Live).
Step 3: Record new version into configuration
Record the new version into config file for Overleaf Toolkit to use the new image when restarting:
echo 5.0.3-with-texlive-full > config/version
Confirm again:
cat config/version
# Result: 5.0.3-with-texlive-full
Note: If you upgrade Overleaf or TeX Live later, you can repeat the steps above to save the customized image.
Summary
- Install full TeX Live in sharelatex container
- Commit container to new image with custom tag
- Record new image name in
config/versionfile - From now on, Overleaf will use this image, no need to reinstall TeX Live every time it runs!
Conclusion
Self-hosting Overleaf Community Edition brings many benefits:
- Full Control: You can customize everything as needed
- Data Security: Data is stored on your server
- Unlimited: No limit on number of projects or users
- Integration: Can integrate with other systems in the organization
However, self-hosting also requires:
- Knowledge of Docker and Linux
- Time for maintenance and updates
- Suitable server resources
If you need a simple online LaTeX solution and don't want to manage a server, Overleaf.com is still the best choice. But if you need full control and have technical capability, Overleaf CE is a great option.
