Linux 获取debian slim的次要版本
我正在设置我的容器创建管道,我需要能够获得容器所构建的debian slim build的主要版本和次要版本 我尝试了以下命令: docker run -it --rm -a stdout --entrypoint lsb_release MyContainer:1.0.0 -a docker run-it--rm-a标准输出--entrypoint lsb_发布MyContainer:1.0.0-a 但这只是返回: Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster 分发服务器ID:Debian 描述:Debian GNU/Linux 10(buster) 发布时间:10 代号:巴斯特 未列出次要版本 我也尝试过: docker run -it --rm -a stdout --entrypoint cat MyContainer:1.0.0 "/etc/os-release" docker run-it-rm-a stdout-entrypoint cat MyContainer:1.0.0“/etc/os发行版” 但这只是产出: PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" PRETTY_NAME=“Debian GNU/Linux 10(buster)” NAME=“Debian GNU/Linux” VERSION_ID=“10” VERSION=“10(buster)” 版本\代号=buster ID=debian 主页地址=”https://www.debian.org/" 支持URL=”https://www.debian.org/support" 错误报告URL=”https://bugs.debian.org/" 同样,没有次要版本Linux 获取debian slim的次要版本,linux,docker,debian,containers,Linux,Docker,Debian,Containers,我正在设置我的容器创建管道,我需要能够获得容器所构建的debian slim build的主要版本和次要版本 我尝试了以下命令: docker run -it --rm -a stdout --entrypoint lsb_release MyContainer:1.0.0 -a docker run-it--rm-a标准输出--entrypoint lsb_发布MyContainer:1.0.0-a 但这只是返回: Distributor ID: Debian Description:
有没有办法获得次要版本?容器操作系统知道它的完整版本号吗?看起来应该更难一些。(发布后立即找到) Debian通过将其放入自定义的、非标准的、特定于Debian的文件
/etc/Debian_version
中来实现这一点,该文件仅在Debian Linux上可用:
docker run -it --rm -a stdout --entrypoint cat MyContainer:1.0.0 "/etc/debian_version"
docker run-it-rm-a stdout-entrypoint cat MyContainer:1.0.0“/etc/debian\u版本”
为什么他们不遵循使用lsb_发行版的标准?
看起来应该更难一些。(发布后立即找到)
Debian通过将其放入自定义的、非标准的、特定于Debian的文件/etc/Debian_version
中来实现这一点,该文件仅在Debian Linux上可用:
docker run -it --rm -a stdout --entrypoint cat MyContainer:1.0.0 "/etc/debian_version"
docker run-it-rm-a stdout-entrypoint cat MyContainer:1.0.0“/etc/debian\u版本”
为什么他们不遵循使用lsb_发行版的标准?
事实上,在Debian9的旧版本中,您可以使用lsb_发行版-a
获得次要版本,如下所示:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.5 (stretch)
Release: 9.5
Codename: stretch
您可能知道,/usr/bin/lsb_release
最终将调用/usr/lib/python3/dist packages/lsb_release.py
,debian9和debian10之间此脚本的实现差异造成了差异
- 在debian9中,它是下一个:
def get_distro_information(): lsbinfo = get_lsb_information() # OS is only used inside guess_debian_release anyway for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',): if key not in lsbinfo: distinfo = guess_debian_release() distinfo.update(lsbinfo) return distinfo else: return lsbinfo
def get_distro_information(): lsbinfo = get_os_release() # OS is only used inside guess_debian_release anyway for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',): if key not in lsbinfo: distinfo = guess_debian_release() distinfo.update(lsbinfo) return distinfo else: return lsbinfo
将获取get\u lsb\u release
的内容,但debian release中没有文件,因此它不会返回任何文件。然后该过程必须回退到/etc/lsb release
,它将从guess\u debian\u release
获取内容,因此您将获得次要版本/etc/debian\u version
- 在debian10中,它是下一个:
def get_distro_information(): lsbinfo = get_lsb_information() # OS is only used inside guess_debian_release anyway for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',): if key not in lsbinfo: distinfo = guess_debian_release() distinfo.update(lsbinfo) return distinfo else: return lsbinfo
def get_distro_information(): lsbinfo = get_os_release() # OS is only used inside guess_debian_release anyway for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',): if key not in lsbinfo: distinfo = guess_debian_release() distinfo.update(lsbinfo) return distinfo else: return lsbinfo
将获取get\u os\u release
的内容,内容如下:/usr/lib/os release
因为它已经得到了版本,所以不再回退到PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
,所以您没有得到次要版本。我想这样做的好处是,如果不使用guess\u debian\u release
,它将使用更少的IO操作,但在我看来,真的是数不胜数(也可能是一些用于guess的硬编码)guess\u debian\u release
$ LSB_OS_RELEASE="" lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10.4 (buster)
Release: 10.4
Codename: buster
事实上,在Debian9的旧版本中,您可以使用
lsb_release-a
获得次要版本,如下所示:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.5 (stretch)
Release: 9.5
Codename: stretch
您可能知道,/usr/bin/lsb_release
最终将调用/usr/lib/python3/dist packages/lsb_release.py
,debian9和debian10之间此脚本的实现差异造成了差异
- 在debian9中,它是下一个:
def get_distro_information(): lsbinfo = get_lsb_information() # OS is only used inside guess_debian_release anyway for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',): if key not in lsbinfo: distinfo = guess_debian_release() distinfo.update(lsbinfo) return distinfo else: return lsbinfo
def get_distro_information(): lsbinfo = get_os_release() # OS is only used inside guess_debian_release anyway for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',): if key not in lsbinfo: distinfo = guess_debian_release() distinfo.update(lsbinfo) return distinfo else: return lsbinfo
将获取get\u lsb\u release
的内容,但debian release中没有文件,因此它不会返回任何文件。然后该过程必须回退到/etc/lsb release
,它将从guess\u debian\u release
获取内容,因此您将获得次要版本/etc/debian\u version
- 在debian10中,它是下一个:
def get_distro_information(): lsbinfo = get_lsb_information() # OS is only used inside guess_debian_release anyway for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',): if key not in lsbinfo: distinfo = guess_debian_release() distinfo.update(lsbinfo) return distinfo else: return lsbinfo
def get_distro_information(): lsbinfo = get_os_release() # OS is only used inside guess_debian_release anyway for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',): if key not in lsbinfo: distinfo = guess_debian_release() distinfo.update(lsbinfo) return distinfo else: return lsbinfo
将获取get\u os\u release
的内容,内容如下:/usr/lib/os release
因为它已经得到了版本,所以不再回退到PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
,所以您没有得到次要版本。我想这样做的好处是,如果不使用guess\u debian\u release
,它将使用更少的IO操作,但在我看来,真的是数不胜数(也可能是一些用于guess的硬编码)guess\u debian\u release
$ LSB_OS_RELEASE="" lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10.4 (buster)
Release: 10.4
Codename: buster
Debian正在使用
lsb\U版本
。由于包在发布过程中经常独立更新,因此了解point release不会告诉您除基本文件
包以外的任何包的任何信息,因此询问此信息只有在高度专业化的情况下才有意义。Debian使用的是lsb_release
。由于包在发布过程中经常独立更新,因此了解point release不会告诉您除基本文件
包之外的任何包的信息,因此询问此信息仅在高度专业化的情况下才有意义。