首页 > 解决方案 > Docker 在 Jenkins 中使用 apt-get install 构建问题

问题描述

我正在尝试使用 JENKINSFILE 在詹金斯内部构建一个 docker 映像。当我在本地构建它时它工作正常,但是在詹金斯上我得到了同伴的输出

本地我使用相同的命令,但它有效。

有没有人知道为什么它不适用于詹金斯?

更新:

+ docker build --no-cache -t app:build .
Sending build context to Docker daemon  11.87MB

Step 1/17 : FROM golang:1.14.3-stretch
 ---> cc1f903b6fe7
Step 2/17 : RUN mkdir -p  /app
 ---> Running in b8a0f9f5c73f
Removing intermediate container b8a0f9f5c73f
 ---> b555e33481ca
Step 3/17 : RUN echo nameserver 8.8.8.8 >> /etc/resolv.conf && cat /etc/resolv.conf
 ---> Running in fb7779fc731a
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 8.8.8.8
Removing intermediate container fb7779fc731a
 ---> 8445167d56f7
Step 4/17 : RUN chmod 777 /etc/resolv.conf
 ---> Running in d910167101cf
Removing intermediate container d910167101cf
 ---> eeb553e7fb83
Step 5/17 : RUN apt-get update && yes | apt-get install libxml2
 ---> Running in 3c09069d085c
Err:1 http://security.debian.org/debian-security stretch/updates InRelease
  Could not resolve 'security.debian.org'
Err:2 http://deb.debian.org/debian stretch InRelease
  Could not resolve 'deb.debian.org'
Err:3 http://deb.debian.org/debian stretch-updates InRelease
  Could not resolve 'deb.debian.org'
Reading package lists...
[91mW: Failed to fetch http://deb.debian.org/debian/dists/stretch/InRelease  Could not resolve 'deb.debian.org'[0m[91m
W: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/InRelease  Could not resolve 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/InRelease  Could not resolve 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
[0mReading package lists...
Building dependency tree...
Reading state information...
Package libxml2 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

[91mE: Package 'libxml2' has no installation candidate[0m[91m
[0mThe command '/bin/sh -c apt-get update && yes | apt-get install libxml2' returned a non-zero code: 100

谢谢!

标签: dockerjenkinsjenkins-pipeline

解决方案


推荐阅读