gpt4 book ai didi

docker - 使用 Jenkins 将 .net 核心添加到 docker 容器

转载 作者:行者123 更新时间:2023-12-04 14:39:12 25 4
gpt4 key购买 nike

我正在尝试创建一个 dockerfile,它将使用 .net core 2.0 和 Jenkins 构建一个镜像。我是 Docker 的新手,但想在我的容器中使用 Jenkins 包含 .net core 2.0,所以我不必担心 .net core 安装在目标机器上,并且可以在我的 Jenkins 中构建 .net core 应用程序容器。我在这里错过了什么吗?

它构建良好,直到它运行 apt-get update 命令,我收到以下错误:
E: Malformed entry 1 in list file /etc/apt/sources.list.d/dotnetdev.list (component)
E: The list of sources could not be read.

我正在使用以下链接在 ubuntu 上安装的步骤:
https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x

我的 Dockerfile 看起来像这样:

FROM jenkins
# Install .NET Core SDK
USER root
RUN mkdir -p /jenkins
WORKDIR /jenkins


ENV DOTNET_CORE_SDK_VERSION 2.0
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >/jenkins/microsoft.gpg
RUN mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
RUN sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
RUN apt-get update
RUN apt-get install dotnet-sdk-2.0.0

最佳答案

在此回复中,您可以使用以下 Dockerfile 将 .NetCore 2 安装到 Jenkins 容器中。您显然可以更进一步,并根据需要安装所需的插件和其他软件。我希望这可以帮助你!

FROM jenkins/jenkins:lts
# Switch to root to install .NET Core SDK
USER root

# Just for my sanity... Show me this distro information!
RUN uname -a && cat /etc/*release

# Based on instructiions at https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x
# Install depency for dotnet core 2.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl libunwind8 gettext apt-transport-https && \
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg && \
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg && \
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/dotnetdev.list' && \
apt-get update

# Install the .Net Core framework, set the path, and show the version of core installed.
RUN apt-get install -y dotnet-sdk-2.0.0 && \
export PATH=$PATH:$HOME/dotnet && \
dotnet --version

# Good idea to switch back to the jenkins user.
USER jenkins

关于docker - 使用 Jenkins 将 .net 核心添加到 docker 容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48104954/

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