gpt4 book ai didi

jenkins - 无法构建openjdk :8-jdk image directly

转载 作者:行者123 更新时间:2023-12-01 09:17:05 25 4
gpt4 key购买 nike

我正在慢慢完成 Riot 控制 Docker 镜像教程 http://engineering.riotgames.com/news/taking-control-your-docker-image 。本教程有点旧,因此最终文件的外观有一些明显的变化。在碰壁后,我决定按照教程的相反顺序进行操作。我成功地将官方 jenkinsci 镜像折叠到我的个人 Dockerfile 中,从 FROM: openjdk:8-dk 开始。但是当我尝试将 openjdk:8-dk 文件折叠到我的个人镜像中时,我收到以下错误

E: Version '8u102-b14.1-1~bpo8+1' for 'openjdk-8-jdk' was not found ERROR: Service 'jenkinsmaster' failed to build: The command '/bin/sh -c set -x && apt-get update && apt-get install -y openjdk-8-jdk="$JAVA_DEBIAN_VERSION" ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" && rm -rf /var/lib/apt/lists/* && [ "$JAVA_HOME" = "$(docker-java-home)" ]' returned a non-zero code: 100 Cosettes-MacBook-Pro:docker-test Cosette$

即使我放弃并直接将 openjdk:8-jdk Dockerfile 复制并粘贴到我自己的 Dockerfile 中,我仍然收到此错误。我的最终目标是将我的个人 Dockerfile 降低到从 debian-jessie 开始的程度。任何帮助将不胜感激。

我的 Dockerfile:

FROM buildpack-deps:jessie-scm

# A few problems with compiling Java from source:
# 1. Oracle. Licensing prevents us from redistributing the official JDK.
# 2. Compiling OpenJDK also requires the JDK to be installed, and it gets
# really hairy.

RUN apt-get update && apt-get install -y --no-install-recommends \
bzip2 \
unzip \
xz-utils \
&& rm -rf /var/lib/apt/lists/*

RUN echo 'deb http://deb.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/jessie-backports.list

# Default to UTF-8 file.encoding
ENV LANG C.UTF-8

# add a simple script that can auto-detect the appropriate JAVA_HOME value
# based on whether the JDK or only the JRE is installed
RUN { \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64

ENV JAVA_VERSION 8u102
ENV JAVA_DEBIAN_VERSION 8u102-b14.1-1~bpo8+1

# see https://bugs.debian.org/775775
# and https://github.com/docker-library/java/issues/19#issuecomment-70546872
ENV CA_CERTIFICATES_JAVA_VERSION 20140324

RUN set -x \
&& apt-get update \
&& apt-get install -y \
openjdk-8-jdk="$JAVA_DEBIAN_VERSION" \
ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" \
&& rm -rf /var/lib/apt/lists/* \
&& [ "$JAVA_HOME" = "$(docker-java-home)" ]

# see CA_CERTIFICATES_JAVA_VERSION notes above
RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure

# Jenkins Specifics

# install Tini
ENV TINI_VERSION 0.9.0
ENV TINI_SHA fa23d1e20732501c3bb8eeeca423c89ac80ed452

# Use tini as subreaper in Docker container to adopt zombie processes
RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static -o /bin/tini && chmod +x /bin/tini \
&& echo "$TINI_SHA /bin/tini" | sha1sum -c -

# Set Jenkins Environmental Variables
ENV JENKINS_HOME /var/jenkins_home
ENV JENKINS_SLAVE_AGENT_PORT 50000
# jenkins version being bundled in this docker image
ARG JENKINS_VERSION
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.19.1}
# jenkins.war checksum, download will be validated using it
ARG JENKINS_SHA=dc28b91e553c1cd42cc30bd75d0f651671e6de0b
ENV JENKINS_UC https://updates.jenkins.io
ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
ENV JAVA_OPTS="-Xmx8192m"
ENV JENKINS_OPTS="--handlerCountMax=300 --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war"
# Can be used to customize where jenkins.war get downloaded from
ARG JENKINS_URL=http://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war
ARG user=jenkins
ARG group=jenkins
ARG uid=1000
ARG gid=1000

# Jenkins is run with user `jenkins`, uid = 1000. If you bind mount a volume from the host or a data
# container, ensure you use the same uid.
RUN groupadd -g ${gid} ${group} \
&& useradd -d "$JENKINS_HOME" -u ${uid} -g ${gid} -m -s /bin/bash ${user}

# Jenkins home directory is a volume, so configuration and build history
# can be persisted and survive image upgrades
VOLUME /var/jenkins_home

# `/usr/share/jenkins/ref/` contains all reference configuration we want
# to set on a fresh new installation. Use it to bundle additional plugins
# or config file with your custom jenkins Docker image.
RUN mkdir -p /usr/share/jenkins/ref/init.groovy.d

# Install Jenkins. Could use ADD but this one does not check Last-Modified header neither does it
# allow to control checksum. see https://github.com/docker/docker/issues/8331
RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \
&& echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha1sum -c -

# Prep Jenkins Directories
USER root
RUN chown -R ${user} "$JENKINS_HOME" /usr/share/jenkins/ref
RUN mkdir /var/log/jenkins
RUN mkdir /var/cache/jenkins
RUN chown -R ${group}:${user} /var/log/jenkins
RUN chown -R ${group}:${user} /var/cache/jenkins

# Expose ports for web (8080) & node (50000) agents
EXPOSE 8080
EXPOSE 50000

# Copy in local config filesfiles
COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groovy
COPY jenkins-support /usr/local/bin/jenkins-support
COPY jenkins.sh /usr/local/bin/jenkins.sh
# NOTE : Just set pluginID to download latest version of plugin.
# NOTE : All plugins need to be listed as there is no transitive dependency resolution.
# from a derived Dockerfile, can use `RUN plugins.sh active.txt` to setup
# /usr/share/jenkins/ref/plugins from a support bundle
COPY plugins.sh /usr/local/bin/plugins.sh
RUN chmod +x /usr/local/bin/plugins.sh
RUN chmod +x /usr/local/bin/jenkins.sh

# Switch to the jenkins user
USER ${user}

# Tini as the entry point to manage zombie processes
ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"]

最佳答案

尝试 JAVA_DEBIAN_VERSION8u111-b14-2~bpo8+1

发生的情况如下:当您构建 docker 文件时,docker 尝试执行 dockerfile 中的所有行。其中之一是 apt 命令:apt-get install -y openjdk-8-jdk="$JAVA_DEBIAN_VERSION"。该命令表示“完全安装 OpenJDK 版本 $JAVA_DEBIAN_VERSION。没有其他内容。”。该版本在 Debian 存储库中不再可用,因此无法 apt-get 安装!我相信官方镜像中的所有软件包都会发生这种情况:如果发布了软件包的新版本,则不再安装旧版本。

如果您想访问较旧的 Debian 软件包,您可以使用类似 http://snapshot.debian.org/ 的内容。 。较旧的 OpenJDK 软件包具有已知的安全漏洞。我建议使用最新版本。

您可以通过在 apt-get 命令中省略显式版本来使用最新版本。另一方面,这会降低你的镜像的可重复性:今天构建镜像可能会得到 u111,明天构建镜像可能会得到 u112。

至于为什么这些指令在另一个 Dockerfile 中起作用,我认为原因是在构建另一个 Dockerfile 时,该包是可用的。所以docker可以apt-get install它。然后 Docker 构建了包含(旧的)OpenJDK 的镜像。该镜像是二进制文件,因此您可以安装它,或者在 FROM 中使用它,不会出现任何问题。但您无法重现该图像:如果您尝试自己构建相同的图像,您将遇到相同的错误。

这也带来了一个有关安全更新的问题:由于 docker 镜像实际上是静态二进制文件(构建一次,捆绑所有依赖项),因此它们一旦构建就不会获得安全更新。您需要跟踪影响您的 docker 镜像的任何安全更新并重建任何受影响的 docker 镜像。

关于jenkins - 无法构建openjdk :8-jdk image directly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40468328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com