![](/img/trans.png)
[英]Why can I not run lsb_release without -a parameter on ubuntu?
[英]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:/#
所以我嘗試安裝它(按照 此處的建議):
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
如果有人試圖處理lsb_release: command not found
on fedora or redhat,要安裝的包是 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。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.