Docker basics for the Scholar Lens stack
A short guide for day-to-day work with scholarlens-stack.yml. Run every command from the repo root (the folder with scholarlens-stack.yml and .env), so Compose reads .env.
Words you will see
- Image: a built, read-only package of a program (like an installer).
docker compose buildmakes images. - Container: a running copy of an image.
docker compose upcreates and starts containers. - Service: one entry in the yml file (
backend,worker,frontend,tts-gpu, ...). Compose runs one container per service. - Project: the group of containers from one yml file. Ours is called
scholarlens(thename:line), so containers are namedscholarlens-<service>-1. - Profile: optional services.
tts,tts-gpu,reranker,searxng,sandboxonly start when their profile is on. The root.envturns them on withCOMPOSE_PROFILES=searxng,reranker,sandbox,tts-gpu. - Volume: storage that survives when a container is removed (the database, the library files, the voice model cache).
Save typing
Add this to ~/.bashrc once, then open a new terminal:
bash
alias sl='docker compose -f ~/Projects/ScholarLens/scholarlens-stack.yml --project-directory ~/Projects/ScholarLens'Every docker compose -f scholarlens-stack.yml ... below can then be written sl ... (for example sl ps).
Look around
| What | Command |
|---|---|
| What is running in this project | docker compose -f scholarlens-stack.yml ps |
| Every container on the machine | docker ps |
| Follow the logs of some services | docker compose -f scholarlens-stack.yml logs -f backend worker |
| Last 100 log lines of the voices | docker compose -f scholarlens-stack.yml logs --tail 100 tts-gpu |
| Open a shell inside a container | docker compose -f scholarlens-stack.yml exec backend bash |
| Disk used by images and volumes | docker system df |
Update only the app (backend, worker, frontend)
After you change code in backend/ or frontend/:
bash
docker compose -f scholarlens-stack.yml up -d --build --no-deps backend worker frontend--buildrebuilds the images from your current code.--no-depsleaves everything else (Postgres,tts-gpu, reranker, ...) alone: it is not restarted or recreated.- Naming the services limits the command to them.
Only one part:
bash
docker compose -f scholarlens-stack.yml up -d --build --no-deps frontendbash
docker compose -f scholarlens-stack.yml up -d --build --no-deps backend workerThe worker uses the backend's image, so rebuild them together.
The voice service (TTS)
Chatterbox on the GPU is the service tts-gpu; Kokoro on the CPU is tts. Use only one.
| What | Command |
|---|---|
| Start or update it | docker compose -f scholarlens-stack.yml up -d --build tts-gpu |
| Restart it (same image) | docker compose -f scholarlens-stack.yml restart tts-gpu |
| Stop it (keeps the container) | docker compose -f scholarlens-stack.yml stop tts-gpu |
| Stop and remove it | docker compose -f scholarlens-stack.yml rm -sf tts-gpu |
| Its logs | docker compose -f scholarlens-stack.yml logs -f tts-gpu |
| Is it healthy? | docker compose -f scholarlens-stack.yml ps tts-gpu |
Naming a service on the command line starts it even when its profile is off in .env. The voice model files live in the tts_cache volume, so removing the container does not download them again.
Podcast videos (optional)
The video service makes an episode's video when someone asks for it (Download › Make a video), in the background, and sends a notice when it is ready. It is off unless you turn it on. The easy way is the installer, which keeps the choice in .env (VIDEO_EXPORT) and rebuilds and starts everything:
bash
./install.sh --video(Windows: .\install.ps1 -Video; --no-video / -NoVideo turns it off.) By hand instead:
- In
.env, addvideotoCOMPOSE_PROFILESand setVIDEO_EXPORT=true. - Build and start it, and restart the backend so it reads
VIDEO_EXPORT:
bash
docker compose -f scholarlens-stack.yml up -d --build --no-deps video backendIts image (about 2.7 GB) adds a headless Chromium to the backend's. Logs: docker compose -f scholarlens-stack.yml logs -f video.
Start, stop, everything
| What | Command |
|---|---|
| Start or update the whole stack | docker compose -f scholarlens-stack.yml up -d --build --wait |
| Stop everything (keeps containers and data) | docker compose -f scholarlens-stack.yml stop |
| Start them again | docker compose -f scholarlens-stack.yml start |
| Remove the containers (keeps data) | docker compose -f scholarlens-stack.yml down |
| Remove containers and all data | docker compose -f scholarlens-stack.yml down -v (deletes the Library, chats, vectors; back up first) |
up is safe to run again and again: it only recreates services whose image or settings changed.
"tts-gpu is already running" and similar errors
Common causes, and what to do:
- Run from another folder, or without
-f scholarlens-stack.yml. Compose then reads a different file or no.env, sees a different project, and trips over the existingscholarlens-*containers or ports. Run from the repo root with-f scholarlens-stack.yml(or use theslalias above). - Port already in use (
Bind for 127.0.0.1:5011 failed: port is already allocated). Something else holds the port: an old container, or a voice service started outside Docker. Find it:docker ps --filter publish=5011andss -ltnp | grep 5011. Stop the old one, then runupagain. - A container left over from an earlier run (
Conflict. The container name ... is already in use). Remove the leftover:docker rm -f scholarlens-tts-gpu-1, then runupagain. - Both voice services on.
ttsandtts-gpushare the addresstts:5010. Keep only one profile inCOMPOSE_PROFILES(or choose with./install.sh --tts=kokoro|chatterbox|none).
If you only wanted to update the app, you did not need to touch tts-gpu at all: use the --no-deps backend worker frontend command above.
Clean up disk space
bash
docker image pruneRemoves old, unused image layers (safe). docker system prune also removes stopped containers and build cache. Never add --volumes unless you mean to delete data.