Docker容器无法apt-get更新或Yum-update

时间:2018-12-28 20:01:32

标签: docker jenkins yum apt-get

我在jenkins服务器上安装了docker。 Jenkin服务器能够成功连接到Internet,并且resolv.conf相同,无论是在Host还是在已创建的容器中。我已经在jenkins服务器(centos,ubuntu)上下载了许多图像,这些图像用于许多不同的工作。 所有这些用于创建容器的詹金斯工作都可以正常进行。 现在突然有些作业停止工作并出现以下错误。

Step 3/21 : RUN yum update -y && yum install epel-release  initscripts policycoreutils selinux-policy-targeted -y --skip-broken
 ---> Running in 5e61a8b671ad
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
[91m

 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64
[0mCould not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was
14: HTTP Error 403 - Forbidden
The command '/bin/sh -c yum update -y && yum install epel-release  initscripts policycoreutils selinux-policy-targeted -y --skip-broken' returned a non-zero code: 1

因此,我尝试直接访问jenkis服务器,并从其他映像手动创建一个新的不同容器,该映像是ubuntu而不是centos(失败的工作之一),并且得到了以下提示:

sudo docker run -ti --name testt cont.azurecr.io/app-be-dev:nginx bash
root@5959696258a0:/# apt-get update
Ign:1 http://deb.debian.org/debian stretch InRelease
Ign:2 http://deb.debian.org/debian stretch-updates InRelease
Ign:3 http://deb.debian.org/debian stretch Release
Ign:4 http://deb.debian.org/debian stretch-updates Release
Ign:5 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:6 http://deb.debian.org/debian stretch/main all Packages
Ign:7 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:8 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:5 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:6 http://deb.debian.org/debian stretch/main all Packages
Ign:7 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:8 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:9 http://security.debian.org/debian-security stretch/updates InRelease
Ign:10 http://security.debian.org/debian-security stretch/updates Release
Ign:11 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:12 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:11 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:5 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:6 http://deb.debian.org/debian stretch/main all Packages
Ign:7 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:8 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:12 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:11 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:12 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:11 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:12 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:5 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:6 http://deb.debian.org/debian stretch/main all Packages
Ign:7 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:8 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:5 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:11 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:12 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:11 http://security.debian.org/debian-security stretch/updates/main all Packages
Err:12 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
  403  Forbidden [IP: 128.101.240.215 80]
Ign:6 http://deb.debian.org/debian stretch/main all Packages
Ign:7 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:8 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Err:5 http://deb.debian.org/debian stretch/main amd64 Packages
  403  Forbidden [IP: 128.31.0.62 80]
Ign:6 http://deb.debian.org/debian stretch/main all Packages
Ign:7 http://deb.debian.org/debian stretch-updates/main all Packages
Err:8 http://deb.debian.org/debian stretch-updates/main amd64 Packages
  403  Forbidden [IP: 128.31.0.62 80]
Reading package lists... Done
W: The repository 'http://deb.debian.org/debian stretch Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'http://deb.debian.org/debian stretch-updates Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'http://security.debian.org/debian-security stretch/updates Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-amd64/Packages  403  Forbidden [IP: 128.31.0.62 80]
E: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/main/binary-amd64/Packages  403  Forbidden [IP: 128.31.0.62 80]
E: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/main/binary-amd64/Packages  403  Forbidden [IP: 128.101.240.215 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
root@5959696258a0:/# apt-get update
Ign:1 http://security.debian.org/debian-security stretch/updates InRelease
Ign:2 http://security.debian.org/debian-security stretch/updates Release
Ign:3 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:4 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:5 http://deb.debian.org/debian stretch InRelease
Ign:6 http://deb.debian.org/debian stretch-updates InRelease
Ign:7 http://deb.debian.org/debian stretch Release
Ign:3 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:8 http://deb.debian.org/debian stretch-updates Release
Ign:4 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:3 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:9 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:4 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:3 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:9 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:4 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:3 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:4 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:9 http://deb.debian.org/debian stretch/main amd64 Packages
Err:3 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
  **403  Forbidden [IP: 128.31.0.63 80]**
Ign:4 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:9 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:9 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Err:9 http://deb.debian.org/debian stretch/main amd64 Packages
  403  Forbidden [IP: 130.89.148.14 80]
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main all Packages
Err:12 http://deb.debian.org/debian stretch-updates/main amd64 Packages
  403  Forbidden [IP: 130.89.148.14 80]
Reading package lists... Done
W: The repository 'http://security.debian.org/debian-security stretch/updates Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'http://deb.debian.org/debian stretch Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'http://deb.debian.org/debian stretch-updates Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/main/binary-amd64/Packages  403  Forbidden [IP: 128.31.0.63 80]
E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-amd64/Packages  403  Forbidden [IP: 130.89.148.14 80]
E: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/main/binary-amd64/Packages  403  Forbidden [IP: 130.89.148.14 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

您还会看到来自其他图像的403错误,并且是手动而不是作业。几天前,由于某些插件实现,唯一在jenkins服务器上出现的事情是重启。 我再说一遍,容器中的resolv.conf与主机(詹金斯)相同,我也尝试了在容器中配置google DNS的docker run -dns 8.8.8.8。

什么可能导致此403错误?我还尝试了jenkins本身的apt-get update,并成功进行了更新。就像在主机上一切正常,但在容器上没有。可能是网桥无法正常工作? 谢谢

UPDATE1

root@4926b1da2bd1:/# cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.1.1     4926b1da2bd1

更新2解决了重新启动docker网络网桥并刷新iptables的问题:

pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d

0 个答案:

没有答案