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

Mic*_*l C 6 docker .net-core dockerfile docker-container

我正在尝试创建一个dockerfile,它将使用.net core 2.0和Jenkins构建映像。我是Docker的新手,但想将.net core 2.0包含在Jenkins的容器中,因此我不必担心.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/zh-cn/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

小智 6

从此响应开始,您可以使用以下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
Run Code Online (Sandbox Code Playgroud)