我只是想快速测试一些东西。所以我运行了一个 docker 容器,我想检查我正在运行哪个版本:
$ docker run -it ubuntu
root@471bdb08b11a:/# lsb_release -a
bash: lsb_release: command not found
root@471bdb08b11a:/#
所以我尝试安装它(如此处建议):
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 及以上版本正在引用。
我发现以下内容将创建从稍后的 Python 安装返回到此
/usr/share
脚本的链接:
sudo ln -s /usr/share/pyshared/lsb_release.py /usr/lib/python3.9/site-packages/lsb_release.py
如果有人试图在 fedora 或 redhat 上处理
lsb_release: command not found
,要安装的软件包是 redhat-lsb-core ,所以 sudo dnf install redhat-lsb-core
在编写 Dockerfile 时,我们可以添加 lsb-release 包 - 像这样
RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install lsb-release -y \
&& apt-get clean all
假设操作系统是 Ubuntu。
如果你运行 docker build
你可以试试
sudo service docker restart