简体   繁体   English

如何在 Docker 中的 Alpine Linux 中安装 Tesseract 3.04(旧)?

[英]How to install Tesseract 3.04 (old) in Alpine Linux, in Docker?

In my Dockerfile, I have在我的 Dockerfile 中,我有

RUN apk update && apk add tesseract-ocr=3.04

Which errors with:哪些错误:

unable to select packages: 
tesseract-ocr-4.1.3-r0:
breaks: world[tesseract-ocr=3.04]

I've also tried add tesseract-ocr=3.04.01 , which is how it's listed on the releases page.我也尝试过add tesseract-ocr=3.04.01 ,这就是它在发布页面上的列出方式。

Simple add tesseract-ocr installs version 4.13, but I need 3.04 specifically.简单add tesseract-ocr安装版本 4.13,但我特别需要 3.04。

Answer in progress:正在回答:

From this question: Install older package version in Alpine来自这个问题: 在 Alpine 中安装较旧的 package 版本

I see that each new version of Alpine updates its packages, tossing out the older versions to stay lean.我看到每个新版本的 Alpine 都会更新它的包,抛弃旧版本以保持精简。

So we need to find the version of Alpine that corresponds to the date that Tesseract 3.04 was released, and use FROM Alpine:3.5 in Dockerfile.所以我们需要找到与 Tesseract 3.04 发布日期对应的 Alpine 版本,并在 Dockerfile 中使用FROM Alpine:3.5

Then add tesseract-ocr will add the only version available in that Alpine version.然后add tesseract-ocr将添加该 Alpine 版本中唯一可用的版本。

It seems that Alpine 3.5 or 3.4 should have Tesseract 3.04.看来 Alpine 3.5 或 3.4 应该有 Tesseract 3.04。

If anyone knows a better way, please shout it out!如果有人知道更好的方法,请大声疾呼!

It's true that Alpine repositories only keep the latest version of each package, and that old package version may still be found in repositories of old Alpine versions.确实,Alpine 存储库仅保留每个 package 的最新版本,并且旧的 package 版本可能仍然可以在旧 Alpine 版本的存储库中找到。 However, you don't necessarily need to revert to an older Alpine version as the base image.但是,您不一定需要恢复到较旧的 Alpine 版本作为基础映像。 Instead, you could instruct apk to install a specific package version from the desired repository.相反,您可以指示apk从所需的存储库安装特定的 package 版本。 This will work if the installed package doesn't have dependencies which conflict with other installed Alpine packages.如果安装的 package 没有与其他安装的 Alpine 包冲突的依赖项,这将起作用。

tesseract-ocr 3.04 is available up to Alpine 3.6: tesseract-ocr 3.04 可用于 Alpine 3.6:
https://pkgs.alpinelinux.org/package/v3.6/community/x86_64/tesseract-ocr https://pkgs.alpinelinux.org/package/v3.6/community/x86_64/tesseract-ocr

For installing it on a newer Alpine image, you should use apk's --repository parameter for specifying the 3.6 community repository.要在较新的 Alpine 映像上安装它,您应该使用 apk 的--repository参数来指定 3.6 社区存储库。 Also, make sure to specify the full version name for tessaract, which is 3.04.01-r1 .此外,请确保指定 tessaract 的完整版本名称,即 3.04.01 3.04.01-r1 For locating the exact package version number, use Alpine's package search .要找到确切的 package 版本号,请使用 Alpine 的package 搜索 Putting it together:把它放在一起:

FROM alpine:3.15
RUN apk update && apk add tesseract-ocr=3.04.01-r1 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.6/community

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM