Dockerfile 看不到本地文件或私有 nuget 服务器 [英] Dockerfile can't see local file or private nuget server

查看:24
本文介绍了Dockerfile 看不到本地文件或私有 nuget 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在容器技术上启动我的 .net 核心 Web api.使用 docker.

I am trying to start my .net core web api on container tech. using docker.

环境=Windows 10、Visual Studio

Environments=Windows 10,Visual Studio

Docker 版本:

客户:

版本:17.12.0-ce

Version: 17.12.0-ce

API 版本:1.35

API version: 1.35

Go 版本:go1.9.2

Go version: go1.9.2

Git 提交:c97c6d6

Git commit: c97c6d6

建成时间:2017 年 12 月 27 日星期三 20:05:22

Built: Wed Dec 27 20:05:22 2017

操作系统/Arch:windows/amd64

OS/Arch: windows/amd64

服务器:

引擎:

版本:17.12.0-ce

Version: 17.12.0-ce

API 版本:1.35(最低版本 1.12)

API version: 1.35 (minimum version 1.12)

Go 版本:go1.9.2

Go version: go1.9.2

Git 提交:c97c6d6

Git commit: c97c6d6

建成时间:2017 年 12 月 27 日星期三 20:12:29

Built: Wed Dec 27 20:12:29 2017

操作系统/Arch:linux/amd64

OS/Arch: linux/amd64

实验性:真实

我的 Nuget.Config 文件:

My Nuget.Config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>


<add key="nuget.org" value="https://api.nuget.org/v3/index.json" 
protocolVersion="3" />


<add key="Private" 
value="http://My_Private_Nuget_Server" />


</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="True" />
</packageManagement>


<apikeys>
<add key="https://www.nuget.org" value="Some_Long_Value" />
</apikeys>


<disabledPackageSources />
</configuration>

我的 Dockerfile:

My Dockerfile:

FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "MailAlertWebApiWithEF.dll"]

我在 Windows 10 机器上使用 Linux Container.我在 Visual Studio 17 上有 .net 核心项目.当我添加 docker 支持并从 VS 17 运行时,一切正常.API在容器内站立.但是当我关闭VS时不起作用.但是,当我尝试自定义我的 dockerfile 以使我的图像和容器独立于 VS 时.由于私有 .dll 导致错误.

I' am using Linux Container on windows 10 machine. I have .net core project on Visual Studio 17. When ı add docker support and run from VS 17 everything works fine. API stands up inside a container.But don't work when i close the VS. However When ı try to customize my dockerfile to make my image and container independent from VS. It gives error because of a private .dll.

在我的项目中,我有一个来自我的私人 nuget 服务器的 .dll.当我尝试没有我的私人 .dll 时,我可以创建图像.但是我需要那个.dll.Docker 给我这个错误:

In my project ı have a .dll from my private nuget server. When ı tried without my private .dll ı can create image. But ı need that .dll. Docker give me this error:

MailAlertWebApiWithEF.csproj:错误 NU1101:无法找到包WebApi.Utils.源中不存在具有此 ID 的软件包:nuget.org

MailAlertWebApiWithEF.csproj : error NU1101: Unable to find package WebApi.Utils. No packages exist with this id in source(s): nuget.org

我搜索了这个错误.问题的根源似乎是 Nuget.Config 文件.但这对我来说似乎很好,因为我可以在那里看到我的私人 nuget 服务器.当我总是在 linux 机器上搜索解决方案箭头但我使用 windows.

I searched this error. The source of problem seems like Nuget.Config file. But it seems good to me because i can see me private nuget server in there. When ı searched the solutions arrows always on linux machines but ı use windows.

1-)因此,如果我可以使用 VS 17 启动我的项目,那么我的 nuget.config 文件格式正确.它可以看到我的私人 nuget 服务器.对?那为什么 docker 看不到呢?

1-)So if i can start my project with VS 17 , then my nuget.config file is in correct form. It can see my private nuget server. Right? Then why not docker don't see it?

请帮忙

推荐答案

为了让在容器内运行的 dotnet 命令找到您的自定义提要,nuget.config 文件也必须复制到容器中.

In order for a dotnet command running inside a container to find your custom feeds, the nuget.config file must also be copied to the container.

为此,请将您的私人提要的 nuget.config 文件添加到您的项目文件夹中,并添加一个额外的 COPY 步骤,将该文件复制到容器中.

To do this, add a nuget.config file with your private feed to your project folder and add an additional COPY step that copies this file to the container.

示例(Dockerfile):

Example (Dockerfile):

WORKDIR ...
COPY NuGet.Config /
COPY ... ...

这篇关于Dockerfile 看不到本地文件或私有 nuget 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆