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

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

问题描述

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

Environments = Windows 10,Visual Studio

Docker版本:

客户:

版本:17.12.0-ce

API版本:1.35

Go版本:go1.9.2

Git提交:c97c6d6

内置:2017年12月27日星期三20:05:22

OS/Arch:windows/amd64

服务器:

引擎:

版本:17.12.0-ce

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

Go版本:go1.9.2

Git提交:c97c6d6

内置:2017年12月27日星期三20:12:29

OS/Arch:linux/amd64

实验:正确

我的Nuget.Config文件:

<?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:

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容器.我在Visual Studio 17上有.net核心项目.当ı添加docker支持并从VS 17运行时,一切正常. API站立在容器中.但是当我关闭VS时不起作用.但是,当我尝试自定义我的dockerfile以使我的映像和容器独立于VS时.由于私有.dll,它会给出错误.

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

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

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

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

请帮助

解决方案

为了使dotnet命令在容器中运行以查找您的自定义供稿,还必须将nuget.config文件复制到容器中.

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

示例(Dockerfile):

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

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

Environments=Windows 10,Visual Studio

Docker version:

Client:

Version: 17.12.0-ce

API version: 1.35

Go version: go1.9.2

Git commit: c97c6d6

Built: Wed Dec 27 20:05:22 2017

OS/Arch: windows/amd64

Server:

Engine:

Version: 17.12.0-ce

API version: 1.35 (minimum version 1.12)

Go version: go1.9.2

Git commit: c97c6d6

Built: Wed Dec 27 20:12:29 2017

OS/Arch: linux/amd64

Experimental: true

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>

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"]

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.

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 : error NU1101: Unable to find package WebApi.Utils. No packages exist with this id in source(s): nuget.org

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-)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?

Please help

解决方案

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.

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.

Example (Dockerfile):

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

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

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