1

RHEL 9 在 WSL2 里不能使用 subscription-manager 注册的解决方法

 1 year ago
source link: https://blog.251.sh/solve-rhel-subscription-manager-is-disabled-when-running-inside-a-container-in-w
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

RHEL 9 在 WSL2 里不能使用 subscription-manager 注册的解决方法

October 13, 2022

很简单的一个解决方法就是了,用不到拷贝文件。

在 WSL 里用 docker 镜像 setup 了一个 RHEL 9 之后,使用 dnf update 时出现了这个提示:

Updating Subscription Management repositories.
Unable to read consumer identity
Subscription Manager is operating in container mode.

This system is not registered with an entitlement server. You can use subscription-manager to register.

好吧,那尝试注册一下:

[root@251 ~]# subscription-manager attach --auto
subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.

看来因为我们使用 docker 镜像作为系统底子,所以并不能直接这样。解决方法也很简单,设置一下 SMDEV_CONTAINER_OFF 这个环境变量即可:

[root@251 ~]# export SMDEV_CONTAINER_OFF=1
[root@251 ~]# subscription-manager attach --auto
This system is not yet registered. Try 'subscription-manager register --help' for more information.
[root@251 ~]# subscription-manager register --username username --password password --auto-attach
Registering to: subscription.rhsm.redhat.com:443/subscription
The system has been registered with ID: 33dfffa7-24e0-448f-b4ec-2f48e05d23e6
The registered system name is: 251
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64
Status:       Subscribed

大功告成!

Update: 一劳永逸的解决方法

通过 Bug#2058540这个 PR 可以知道,目前 subscription-manager 是通过以下这三个目录探测是否为 docker 环境:

/run/.containerenv
/.dockerenv
/etc/rhsm-host/

而我生成的系统镜像内存在 /.dockerenv,故直接删除即可解决这个问题。


如果喜欢本文,欢迎点击下方的「鼓掌」按钮!

如果上面没有加载出任何东西,可以点击这里


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK