Docker: how to copy and install packages from previous build layer?

Viewed 373

I need a package version (tesseract-ocr 3.04) that I can only get from Debian 9; then I switch to a later Debian.

The problem is that I can't seem to COPY the package in such a way that it's installed in the next stage.

Here's where I'm at:

Dockerfile:

FROM debian:9 as builder

RUN apt update && apt install -y tesseract-ocr

FROM debian

COPY --from=builder [???]

I've tried copying all the spots where I can find tesseract-ocr into their equivalent locations, but

  1. I'm not sure I'm actually capturing everything

  2. If I try to interactively check tesseract's version later, it says tesseract isn't installed. (As a sanity check, it does install correctly in the first RUN step.)

How can I copy the package from Debian 9 into the next FROM stage in such a way that it's actually installed?

0 Answers
Related