ЗАПУСК Docker yum -y install epel-release вызывает ОШИБКУ

#linux #docker #sh

#linux #docker #sh

Вопрос:

Я использую dockerfile с состоянием, подобным приведенному ниже :

RUN yum -y install epel-release amp;amp; yum clean all

во время построения образа он интерпретирует:

/bin/sh -c yum -y install epel-release

Затем это вызывает ошибку, как показано ниже:

 ERROR:kolla.image.build.base:Error'd with the following message
ERROR:kolla.image.build.base:The command '/bin/sh -c yum -y install epel-release  amp;amp; yum clean all' returned a non-zero code: 1
  

Я тестирую это /bin/sh -c yum -y install epel-release amp;amp; yum clean all состояние на своей машине CentOS 7. Результат, как показано ниже.

 [root@openstack-test ~]# /bin/sh -c yum -y install epel-release
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, priorities
You need to give some command
Usage: yum [options] COMMAND

List of Commands:

check          Check for problems in the rpmdb
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade      downgrade a package
erase          Remove a package or packages from your system
fs             Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot     Creates filesystem snapshots, or lists/deletes current snapshots.
groups         Display, or use, the groups information
help           Display a helpful usage message
history        Display, or use, the transaction history
info           Display details about a package or group of packages
install        Install a package or packages on your system
list           List a package or groups of packages
load-transaction load a saved transaction from filename
makecache      Generate the metadata cache
provides       Find what package provides the given value
reinstall      reinstall a package
repo-pkgs      Treat a repo. as a group of packages, so we can install/remove all of them
repolist       Display the configured software repositories
search         Search package details for the given string
shell          Run an interactive yum shell
swap           Simple way to swap packages, instead of using shell
update         Update a package or packages on your system
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo     Acts on repository update information
upgrade        Update packages taking obsoletes into account
version        Display a version for the machine and/or available repos.


Options:
  -h, --help            show this help message and exit
  -t, --tolerant        be tolerant of errors
  -C, --cacheonly       run entirely from system cache, don't update cache
  -c [config file], --config=[config file]
                        config file location
  -R [minutes], --randomwait=[minutes]
                        maximum command wait time
  -d [debug level], --debuglevel=[debug level]
                        debugging output level
  --showduplicates      show duplicates, in repos, in list/search commands
  -e [error level], --errorlevel=[error level]
                        error output level
  --rpmverbosity=[debug level name]
                        debugging output level for rpm
  -q, --quiet           quiet operation
  -v, --verbose         verbose operation
  -y, --assumeyes       answer yes for all questions
  --assumeno            answer no for all questions
  --version             show Yum version and exit
  --installroot=[path]  set install root
  --enablerepo=[repo]   enable one or more repositories (wildcards allowed)
  --disablerepo=[repo]  disable one or more repositories (wildcards allowed)
  -x [package], --exclude=[package]
                        exclude package(s) by name or glob
  --disableexcludes=[repo]
                        disable exclude from main, for a repo or for
                        everything
  --disableincludes=[repo]
                        disable includepkgs for a repo or for everything
  --obsoletes           enable obsoletes processing during updates
  --noplugins           disable Yum plugins
  --nogpgcheck          disable gpg signature checking
  --disableplugin=[plugin]
                        disable plugins by name
  --enableplugin=[plugin]
                        enable plugins by name
  --skip-broken         skip packages with depsolving problems
  --color=COLOR         control whether color is used
  --releasever=RELEASEVER
                        set value of $releasever in yum config and repo files
  --downloadonly        don't update, just download
  --downloaddir=DLDIR   specifies an alternate directory to store packages
  --setopt=SETOPTS      set arbitrary config and repo options
  --bugfix              Include bugfix relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory=ADVS, --advisories=ADVS
                        Include packages needed to fix the given advisory, in
                        updates
  --bzs=BZS             Include packages needed to fix the given BZ, in
                        updates
  --cves=CVES           Include packages needed to fix the given CVE, in
                        updates
  --sec-severity=SEVS, --secseverity=SEVS
                        Include security relevant packages matching the
                        severity, in updates

  Plugin Options:
    --samearch-priorities
                        Priority-exclude packages based on name   arch
  

Когда я использую другую команду, подобную приведенной ниже, она выполняется правильно.

 [root@openstack-test ~]# /bin/sh -c ls anaconda-ks.cfg
anaconda-ks.cfg  pike-stable
  

Затем я попытался использовать эту форму команды, она также может работать правильно.

 [root@openstack-test ~]# /bin/sh -c "yum install epel-release"
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
 * base: mirror.dal10.us.leaseweb.net
 * centos-qemu-ev: mirror.dal10.us.leaseweb.net
 * epel: packages.oit.ncsu.edu
 * extras: centos.s.uw.edu
 * updates: mirror.dal10.us.leaseweb.net
Package epel-release-7-12.noarch already installed and latest version
Nothing to do
[root@openstack-test ~]# /bin/sh -c "yum -y install epel-release"
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
 * base: mirror.dal10.us.leaseweb.net
 * centos-qemu-ev: mirror.dal10.us.leaseweb.net
 * epel: packages.oit.ncsu.edu
 * extras: centos.s.uw.edu
 * updates: mirror.dal10.us.leaseweb.net
Package epel-release-7-12.noarch already installed and latest version
Nothing to do
  

Тогда версия /bin/sh :

 [root@openstack-test ~]# /bin/sh -version
GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3 : GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[root@openstack-test ~]#
  

Почему это происходит, как я могу решить и избежать этой проблемы.

Пожалуйста, помогите, большое спасибо.

Комментарии:

1. какой образ контейнера вы используете? установил ли его yum?

2. Привет @confusedgenius, я использую изображение centos: 7 в качестве базового изображения. У него есть команда yum. Вы знаете, что RUN xxx интерпретируется? /bin/sh -c "xxxx" или /bin/sh -c xxxx

3. // RUN echo hi # sh -c echo hi (Linux and LCOW) Я вижу этот комментарий moby/builder/dockerfile/dispatchers.go в. Если вы выполняете этот путь, у команды не может быть никаких опций, верно?

4. INFO:kolla.image.build.base:Step 1/35 : FROM centos:7

5. Обратите внимание, что это /bin/sh -c занимает один аргумент, вам не хватает кавычек в команде в ваших примерах. Например. вы хотите /bin/sh -c "ls anaconda-ks.cfg"

Ответ №1:

Я обнаружил проблему, она не вызывается командой запуска Dockerfile. это вызвано этой ссылкой репо: https://trunk.rdoproject.org/centos7-pike/delorean-deps.repo .

Эта ссылка на репозиторий больше не существует. Поэтому он показывает ошибку:

 Step 26/35 : RUN yum -y install epel-release yum-plugin-priorities centos-release-ceph-jewel centos-release-opstools centos-release-qemu-ev amp;amp; yum clean all
 ---> Running in b9f64321e50e
Loaded plugins: fastestmirror, ovl


File contains no section headers.
file: file:///etc/yum.repos.d/delorean-deps.repo, line: 1
'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">n'
The command '/bin/sh -c yum -y install epel-release yum-plugin-priorities centos-release-ceph-jewel centos-release-opstools centos-release-qemu-ev amp;amp; yum clean all' returned a non-zero code: 1