Linux

如何處理yum repolist is 0yum list empty

  • December 1, 2019

我在 centos 7 主機上執行 docker 映像(gitlab-runner)。在容器中,奇怪的是有apt命令卻沒有yum命令。但是系統好像是centos而不是ubuntu?

root@vultr:/usr/local/java# uname -r 
3.10.0-1062.4.1.el7.x86_64

我用apt-get install yum 安裝yum,然後我想做yum update,但是出現如下問題,如何處理?

   root@vultr:/usr/local/java# yum update      
   There are no enabled repos.
   Run "yum repolist all" to see the repos you have.
   You can enable repos with yum-config-manager --enable <repo>
   root@vultr:/usr/local/java# yum repolist all
   repolist: 0
   root@vultr:/usr/local/java# yum list
   root@vultr:/usr/local/java#
   root@vultr:/usr/local/java#
   root@vultr:/usr/local/java# yum-config-manager --enable
   Error: Trying to enable already enabled repos.
   ==================================================================================================== main ====================================================================================================
   [main]
   alwaysprompt = True
   assumeyes = False
   bandwidth = 0
   bugtracker_url = http://yum.baseurl.org/report
   cache = 0
   cachedir = /var/cache/yum
   clean_requirements_on_remove = False
   color = auto
   color_list_available_downgrade = dim,cyan
   color_list_available_install = normal
   color_list_available_reinstall = bold,underline,green
   color_list_available_upgrade = bold,blue
   color_list_installed_extra = bold,red
   color_list_installed_newer = bold,yellow
   color_list_installed_older = bold
   color_list_installed_reinstall = normal
   color_search_match = bold
   color_update_installed = normal
   color_update_local = bold
   color_update_remote = normal
   commands =
   debuglevel = 2
   diskspacecheck = True
   distroverpkg = redhat-release
   enable_group_conditionals = True
   enabled = True
   enablegroups = True
   errorlevel = 2
   exactarch = True
   exactarchlist = kernel,
      kernel-smp,
      kernel-hugemem,
      kernel-enterprise,
      kernel-bigmem,
      kernel-devel,
      kernel-PAE,
      kernel-PAE-debug
   exclude =
   exit_on_lock = False
   failovermethod = roundrobin
   gaftonmode = False
   gpgcheck = False
   group_package_types = mandatory,
      default
   groupremove_leaf_only = False
   history_list_view = single-user-commands

GitLab Runner 映像基於 Ubuntu 或 Alpine Linux。這在文件中有所說明:

可以使用以下 Docker 映像:

  • gitlab/gitlab-runner:latest基於 Ubuntu。
  • gitlab/gitlab-runner:alpine基於 Alpine,佔用空間更小(~160/350 MB Ubuntu vs ~45/130 MB Alpine 壓縮/解壓縮)。

Ubuntu 和 Alpine Linux 都有自己的包管理系統 -apt並且apk分別。您可以使用這些包管理器在容器內添加/刪除包。yum是 RHEL/Fedora 類 Linux 發行版的包管理器,Ubuntu 或 Alpine Linux 均不使用。

引用自:https://unix.stackexchange.com/questions/554976