【M1Mac × Docker】关于使CentOS可使用less命令的故事
前置条件
操作系统
MacOS Monterey 12.0.1
中央处理器
Apple M1(arm64)
Docker
Docker桌面版 4.2.0 (70708)
CentOS
CentOS Linux 7.9.2009版本 (AltArch)
想做的事情
在运行在Docker容器上的CentOS 7中,想要使用less命令。
绊倒的故事
[root@0a412e1af0a1 ~]# less -N bunsyo2.txt
bash: less: command not found
似乎无法使用less命令。
bash:less:找不到命令。
解决办法
在yum(※)中安装less命令。
yum install less
在各种琐事中,安装成功
(因为要多次询问是否可以安装,所以全部选择y(是)作为答案)
如果加上”-y”选项,可以一切用「是」来回答并继续进行。
[root@0a412e1af0a1 ~]# yum install less
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
* base: ftp.yz.yamagata-u.ac.jp
* extras: ftp.yz.yamagata-u.ac.jp
* updates: ftp.yz.yamagata-u.ac.jp
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): base/7/aarch64/group_gz | 153 kB 00:00:00
(2/4): base/7/aarch64/primary_db | 4.9 MB 00:00:02
(3/4): extras/7/aarch64/primary_db | 246 kB 00:00:06
(4/4): updates/7/aarch64/primary_db | 2.1 MB 00:00:07
Resolving Dependencies
--> Running transaction check
---> Package less.aarch64 0:458-9.el7 will be installed
--> Processing Dependency: groff-base for package: less-458-9.el7.aarch64
--> Running transaction check
---> Package groff-base.aarch64 0:1.22.2-8.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================
Installing:
less aarch64 458-9.el7 base 115 k
Installing for dependencies:
groff-base aarch64 1.22.2-8.el7 base 920 k
Transaction Summary
==================================================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 1.0 M
Installed size: 4.1 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/aarch64/7/base/packages/groff-base-1.22.2-8.el7.aarch64.rpm: Header V4 RSA/SHA1 Signature, key ID 305d49d6: NOKEY
Public key for groff-base-1.22.2-8.el7.aarch64.rpm is not installed
(1/2): groff-base-1.22.2-8.el7.aarch64.rpm | 920 kB 00:00:01
(2/2): less-458-9.el7.aarch64.rpm | 115 kB 00:00:06
----------------------------------------------------------------------------------------------------------------------------------
Total 169 kB/s | 1.0 MB 00:00:06
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-9.2009.0.el7.centos.aarch64 (@instCentOS)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64
Importing GPG key 0x305D49D6:
Userid : "CentOS AltArch SIG - AArch64 (http://wiki.centos.org/SpecialInterestGroup/AltArch/AArch64) <security@centos.org>"
Fingerprint: ef8f 3ca6 6efd f32b 36cd adf7 6c7c b6ef 305d 49d6
Package : centos-release-7-9.2009.0.el7.centos.aarch64 (@instCentOS)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : groff-base-1.22.2-8.el7.aarch64 1/2
Installing : less-458-9.el7.aarch64 2/2
Verifying : less-458-9.el7.aarch64 1/2
Verifying : groff-base-1.22.2-8.el7.aarch64 2/2
Installed:
less.aarch64 0:458-9.el7
Dependency Installed:
groff-base.aarch64 0:1.22.2-8.el7
Complete!
我现在可以使用less命令了,如果还有其他不能使用的命令,我也可以通过相同的步骤来使用。(由于我也不能使用显示命令手册的“man命令”。)
yum install man
现在我已经能够使用它了。
※補充:
据说yum是”Yellowdog Updater Modified”的缩写。
请参考以下页面