lsb_release: 在最新的 Ubuntu Docker 容器中找不到命令

lsb_release: command not found in latest Ubuntu Docker container

我只是想快速测试一些东西。所以我 运行 一个 docker 容器,我想检查我是哪个版本 运行:

$ docker run -it ubuntu    
root@471bdb08b11a:/# lsb_release -a
bash: lsb_release: command not found
root@471bdb08b11a:/# 

所以我尝试安装它(如 suggested here):

root@471bdb08b11a:/# apt install lsb_release
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package lsb_release
root@471bdb08b11a:/# 

有人知道为什么这不起作用吗?

好像lsb_release没有安装。

您可以通过

安装它
apt-get update && apt-get install -y lsb-release && apt-get clean all

希望对您有所帮助 ;)

此错误可能是由于卸载或升级 ubuntu 16.04

中的默认 python3 程序版本所致

纠正此问题的方法是重新安装 ubuntu 附带的原始 python3 版本并再次重新链接。 (在 ubuntu 16.04 - 默认 python3 版本是 python 3.5

sudo rm /usr/bin/python3
sudo ln -s /usr/bin/python3.5 /usr/bin/python3

lsb_release.py 居住在 /usr/share/pyshared 中,在我看来 python3.6 及以上是引用。

我发现以下内容会创建 link 从稍后的 Python 安装到 /usr/share 脚本:

sudo ln -s /usr/share/pyshared/lsb_release.py /usr/lib/python3.9/site-packages/lsb_release.py