TL;DR: TESSDATA_PREFIX is pointing at a directory that does not exist inside the container, so tesseract falls back to the relative path ./tessdata and finds nothing. Find where eng.traineddata actually lives in the image, set TESSDATA_PREFIX to that absolute path, and re-run. One ENV line in the Dockerfile fixes it permanently.

```text
Error opening data file ./tessdata/eng.traineddata
```

1. Confirm the failure and inspect the variable inside the container:
   `docker exec [container] sh -c 'echo "TESSDATA_PREFIX=$TESSDATA_PREFIX"; tesseract --version'`
   Expected: TESSDATA_PREFIX is empty or a path that does not exist in the image.
2. Find the real traineddata location:
   `docker exec [container] find /usr -name "eng.traineddata"`
   Expected: a path like /usr/share/tesseract-ocr/5/tessdata/eng.traineddata.
3. Test the fix in a throwaway run using the path from step 2:
   `docker exec -e TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata [container] tesseract scan.png stdout`
   Expected: OCR text prints instead of the data-file error.
4. Make it permanent in the Dockerfile:
   `ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata`
   then rebuild and re-run.
   Expected: the error is gone on every run with no manual env flags.
5. If step 2 finds nothing, the language pack is not installed: add `tesseract-ocr-eng` to the image package install step and rebuild.
   Expected: eng.traineddata appears under the tessdata directory.

## Use this when
- tesseract works on your dev machine but fails in Docker with the data-file error
- the error path starts with ./tessdata
- you built a custom image or switched base images recently

## Not for this skill when
- the error names a different language (e.g. fra.traineddata) - that is a missing language pack; install that pack instead
- tesseract is not installed at all in the image (command not found)
- the error happens outside Docker - check the local TESSDATA_PREFIX instead

## Variant phrasings
### tesseract docker Error opening data file eng.traineddata
### tesseract TESSDATA_PREFIX docker not working
### tesseract failed loading language eng in container

## Why it happens
When TESSDATA_PREFIX is unset or relative, tesseract resolves ./tessdata against the working directory. Local installs usually carry a correct compiled-in default, but Docker images (especially slim or multi-stage builds) often lack the env var or place traineddata somewhere the default does not cover.

## Edge cases
- Point TESSDATA_PREFIX at the tessdata directory itself, not its parent; a trailing slash matters on some builds.
- Debian splits the packs: `tesseract-ocr` alone ships no languages, so install `tesseract-ocr-eng` (or the pack you need).
- If you mount a custom tessdata volume, the mount must land exactly at TESSDATA_PREFIX.
- The error is about location, not model flavor - tessdata_fast vs tessdata_best makes no difference here.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_PiqZwtHlr-V8_aRMZ3cJzg
