我正在尝试配置一个容器来运行我的构建。(它是一个windows核心容器。)
当我在docker文件中运行nuget命令时,它会失败。但是,当我将powershell连接到容器时,它运行得很好。
这是有关的命令:
nuget sources Add -Name "Common Source" -Source http://CompanyPackages/nuget/Common我像这样从码头文件中运行它:
RUN nuget sources Add -Name "Common Source" -Source http://CompanyPackages/nuget/Common并得到以下错误:
sources: invalid arguments.但是,当我接受容器并使用以下方法启动它时:
docker run -it agent:v1然后在容器中运行相同的命令:
nuget sources Add -Name "Common Source" -Source http://CompanyPackages/nuget/Common结果是:
Package Source with Name: Common added successfully.是什么导致它在dockerfile中而不是在容器中失败?
注意:
如果有用的话,下面是我的完整docker文件:
FROM sixeyed/msbuild:netfx-4.5.2-webdeploy AS build-agent
SHELL ["powershell"]
RUN nuget sources Add -Name "Common Source" -Source http://CompanyPackages/nuget/Common发布于 2019-08-12 09:20:56
我试过了,让它像这样工作:
如果您像这样更改Dockerfile的内容:
FROM sixeyed/msbuild:netfx-4.5.2-webdeploy AS build-agent
SHELL ["powershell"]
RUN ["nuget", "sources" , "Add", "-Name", "\"Common Source\"", "-Source" ,"http://CompanyPackages/nuget/common"]当您运行docker build -t yourImageName .时
你最后的下场是:
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM sixeyed/msbuild:netfx-4.5.2-webdeploy AS build-agent
---> 0851a5b495a3
Step 2/3 : SHELL ["powershell"]
---> Running in 10082a1c45f8
Removing intermediate container 10082a1c45f8
---> c00b912c6a8f
Step 3/3 : RUN ["nuget", "sources" , "Add", "-Name", "\"Common Source\"", "-Source" ,"http://CompanyPackages/nuget/common"]
---> Running in 797b6c055928
Package Source with Name: "Common Source" added successfully.
Removing intermediate container 797b6c055928
---> 592db3be9f8b
Successfully built 592db3be9f8b
Successfully tagged nuget-tester:latesthttps://stackoverflow.com/questions/56860764
复制相似问题