Search code examples
asp.netdocker.net-coredocker-composedocker-for-windows

Docker: Running dotnet publish -o /output results in a nonzero error on CLI


I'm using Ubuntu 16.04 LTS,


Docker-compose v 1.18.0-rc2, build 189468b
Docker version 17.12.0-ce-rc1, build ee2f943

Running this command: dotnet publish -o /output with docker results in this error:


ERROR: Service 'generator' failed to build: The command '/bin/sh -c 
dotnet publish -c Release -o out' returned a non-zero code: 145

enter image description here

I've installed the .NET SDK for Ubuntu and not sure how to resolve this error; it just won't create that publish folder; here's dotnet --info

joel@worker-2:~/workspace/asp (copy)/api$ dotnet --info .NET Command Line Tools (2.0.2)

Product Information: Version: 2.0.2 Commit SHA-1 hash: a04b4bf512

Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64 Base Path:
/usr/share/dotnet/sdk/2.0.2/

Microsoft .NET Core Shared Framework Host

Version : 2.0.0 Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

Link to the same question worded differently with more error logs


Solution

  • The error you are seeing is because your project contains a global.json file that pins the required SDK version to 2.0.2. However, the docker images contain newer SDK versions (current one is 2.1.3) which. Because no 2.0.2 SDK is present in the docker image you use to build, it just errors out.