[英]Install specific version of apt package for specific ubuntu version
I want to install package foo
version 1234
in a docker container. 我想在Docker容器中安装
foo
版本1234
软件包。 I prefer this to the latest version, as it will always work the same way. 与最新版本相比,我更喜欢它,因为它将始终以相同的方式工作。
So my Dockerfile has this: 所以我的Dockerfile有这个:
RUN apt-get update && apt-get install -y foo=1234
But the base image is mongodb:4.0.2
, which is layered on Ubuntu xenial. 但是基本映像是
mongodb:4.0.2
,它位于Ubuntu xenial上。
When I build the image, the apt install fails because it cannot find that version. 构建映像时,apt安装失败,因为它找不到该版本。 I think xenial doesn't support that version.
我认为xenial不支持该版本。
So how do I find the latest supported version of a package foo
on xenial? 那么,如何在xenial上找到软件包
foo
的最新受支持版本? If I run apt policy foo
it shows me the latest for the ubuntu I'm using (bionic), not for xenial. 如果我运行
apt policy foo
它将显示我正在使用的ubuntu的最新信息(仿生),而不是xenial的最新信息。
If the package at stake is, say, rlwrap
, you could just take a look at the webpage https://packages.ubuntu.com/xenial/rlwrap 如果所涉及的软件包是
rlwrap
,则可以仅查看网页https://packages.ubuntu.com/xenial/rlwrap
But if you want a proper way to get this version info programatically, you can rely on the Launchpad API , which comes with an official API client implemented as a Python library . 但是,如果您希望以适当的方式以编程方式获取此版本信息,则可以依赖Launchpad API ,该API附带有作为Python库实现的正式API客户端 。
Otherwise, you can directly query the API with tools such as curl
and jq
(to parse the retrieved JSON data): 否则,您可以使用
curl
和jq
等工具直接查询API(以解析检索到的JSON数据):
$ curl -fsSL "https://api.launchpad.net/1.0/ubuntu/+archive/primary?ws.op=getPublishedSources&source_name=rlwrap&exact_match=true&distro_series=https://api.launchpad.net/1.0/ubuntu/xenial" \
| jq --raw-output ".entries | .[0] | .source_package_version"
→ 0.41-1build1
As mentioned in this Askubuntu question , a similar API exists for Debian as well. 就像这个Askubuntu问题中提到的那样 ,Debian也存在类似的API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.