简体   繁体   English

`lsb_release -a` 在 `opensuse/tumbleweed` docker 中

[英]`lsb_release -a` inside an `opensuse/tumbleweed` docker

Context语境

When trying to install a python3 package using尝试使用安装 python3 包时

python3 -m pip install absl-py

It fails if lsb-release package is installed (which is my case and mandatory).如果安装了lsb-release包,它会失败(这是我的情况并且是强制性的)。

After digging I've found, pip will internally call lsb_release -a which will lead to this error... I can easily reproduce it using the following Dockerfile挖掘后我发现,pip 将在内部调用lsb_release -a这将导致此错误...我可以使用以下 Dockerfile 轻松重现它

Protocol协议

Create this Dockerfile :创建这个Dockerfile

# ref: https://hub.docker.com/r/opensuse/tumbleweed
FROM opensuse/tumbleweed

RUN zypper update -y \
&& zypper install -y lsb-release \
&& zypper clean -a

RUN lsb_release -a

Observed观察到的

docker build --tag=so .
...
 ---> 8330cfe918d5
Step 3/3 : RUN lsb_release -a
 ---> Running in 488762fb27a3
/usr/bin/lsb_release: line 122: getopt: command not found
The command '/bin/sh -c lsb_release -a' returned a non-zero code: 2

Tests测试

I've tried to install "gengetopt", "gnu-getopt" or "perl-Getopt-Long-Descriptive" without success (ed still the same error occurred).我尝试安装“gengetopt”、“gnu-getopt”或“perl-Getopt-Long-Descriptive”但没有成功(仍然出现同样的错误)。

Workaround解决方法

One workaround is to install the meta package lsb unfortunately it take time (184 packages).一种解决方法是安装元包lsb不幸的是它需要时间(184 个包)。

I'm looking for a "smaller" package to fix it (ie pulling less dependencies).我正在寻找一个“更小”的包来修复它(即减少依赖)。

Protocol协议

FROM opensuse/tumbleweed

RUN zypper update -y \
&& zypper install -y lsb-release \
&& zypper clean -a

RUN zypper update -y \
&& zypper install -y lsb \
&& zypper clean -a

RUN lsb_release -a

Observed观察到的

docker build --tag=workaround .
...
Step 4/4 : RUN lsb_release -a
 ---> Running in 6d93c78f7a47
LSB Version:    core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64:desktop-4.0.fake-amd64:desktop-4.0.fake-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0.fake-amd64:graphics-4.0.fake-noarch
Distributor ID: openSUSE
Description:    openSUSE Tumbleweed
Release:    20201121
Codename:   n/a
Removing intermediate container 6d93c78f7a47
 ---> c11779133426
Successfully built c11779133426
Successfully tagged os:latest

You can retrieve the package owner of getopt using zypper search -f <file> :您可以使用zypper search -f <file>检索getopt的包所有者:

15b83d17ed60:/ # command -v getopt
/usr/bin/getopt
15b83d17ed60:/ # command -v getopt | xargs zypper search -f 
Loading repository data...
Reading installed packages...

S | Name               | Summary                                | Type
--+--------------------+----------------------------------------+--------
  | busybox-util-linux | Busybox applets replacing util-linux   | package
i | util-linux         | A collection of basic system utilities | package

So here, installing util-linux should be enough....所以到这里,安装util-linux应该就够了....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM