1

I am deploying .net core app to Docker.

My docker file is as follows, which is added in my .net core application:

FROM microsoft/dotnet:1.1-sdk-projectjson

COPY . /app
WORKDIR /app

RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]

EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000

ENTRYPOINT ["dotnet", "run"]

Its not able to resolve .net standard class libraries, which are added to my .net core application.

My project structure is as follows:

Core folder

   -Logging.Interfaces .net std project

   -Logging.Entities .net std project

Infrastructure folder

   -Infrastructure.Logging .net std project

Services folder

   -Services .net std project

Web folder

   -Web .net core application

Dependencies section of project.json of Web application is as follows:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Services": "1.0.0-*",
    "DomainInterfaces": "1.0.0-*",
    "Core.Logging.Interfaces": "1.0.0-*",
    "Core.Logging.Entities": "1.0.0-*",
    "Infrastructure.Logging": "1.0.0-*"
  },

When I run following command, for creating image, it gives me error:

user@machine_name MINGW64 path to solution
$  docker build -t helloWorld:core .

Unable to resolve 'Core.Logging.Interfaces (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
    Unable to resolve 'Core.Logging.Entities (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
    Unable to resolve 'Services (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
    Unable to resolve 'Infrastructure.Logging (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
    Unable to resolve 'DomainInterfaces (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.

Can someone please guide, what is going wrong over here, as I am completely new to Docker.

4
  • where do you save dockerfile? Commented Feb 13, 2017 at 8:33
  • My docker file is in web project, which is .net core application. And all other projects are added as reference in my web application. Commented Feb 13, 2017 at 8:39
  • You should be tried to place dockerfile in solution as /src folder. Commented Feb 13, 2017 at 8:52
  • I tried your suggestion, but still same issue. Commented Feb 13, 2017 at 8:56

2 Answers 2

0

I think you should be tried to create a Dockerfile on solution level as following structure:

/YourProject

  • src
    • Core
    • Infrastructure
    • Services
    • WebApp
  • Dockerfile

And changes content of Dockerfile to:

FROM microsoft/dotnet:1.1-sdk-projectjson

COPY . /app
WORKDIR /app/src/WebApp

RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]

EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000

ENTRYPOINT ["dotnet", "run"]

Hope this help!

Sign up to request clarification or add additional context in comments.

2 Comments

When I change Dockerfile, and run docker build command, I get "Couldn't find 'project.json' in current directory" error.
Could you please have a look at the answer and check the structure again?
0

My dot net core application does not have a project.json file either. I fixed my problem with the follow: FROM microsoft/dotnet:1.1-sdk instead of FROM microsoft/dotnet:1.1-sdk-projectjson

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.