4

I have installed ASP.NET Core 2.1 preview 1 from here and the latest preview of Visual Studio.

Then I follow the steps: File > New Project > ASP.NET Core Web Application > Choose API, check Enable Docker Support (Os: Linux) and No Authentication.

This nicely generates project template, as well as a Docker project with docker compose files. This builds fine, and pulls all the required images. However, when I try to run it with Docker, from within Visual Studio, it doesn't seem to work.

In the logs I see the following:

Content root path: /app
Now listening on: http://[::]:80
...
Request starting HTTP/1.1 GET http://localhost:32778/ Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:32778/

Now, when I try to do a GET to http://localhost:32778/api/values (using Postman), no response is seen:

Could not get any response There was an error connecting to http://localhost:32778/api/values.

BUT! The Docker logs show that the request is being made:

Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:32778/api/values
[40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[1] Request starting HTTP/1.1 GET http://localhost:32778/api/values
[40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[2] Request finished in 14.4873ms 307 Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 14.4873ms 307

What am I missing here? If I run the default project with IIS Express, everything works as expected.

EDIT: I've just tested this on ASP.NET Core 2.0, and everything works just fine.

2 Answers 2

8

As @andrewbadera pointed out, the repositories changed:

SDK

Old : microsoft/aspnetcore-build:2.0

New: microsoft/dotnet:2.1-sdk

ASP NET

Old : microsoft/aspnetcore:2.0

New: microsoft/dotnet:2.1-aspnetcore-runtime

I don't know why the template from visual studio is not using it already, but soon they probably will fix this.

Visual Studio template is generating:

SDK => microsoft/aspnetcore:2.1

ASP NET => microsoft/aspnetcore-build:2.1

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

Comments

1

I'm also struggling with netcoreapp2.1 on Docker. Are you sure that docker images are pulled down successfully? Because when I'm creating a new project, the created Dockerfile has:

FROM microsoft/aspnetcore:2.1 AS base
//...
//...
FROM microsoft/aspnetcore-build:2.1 AS build

and from what I can see in the microsoft docker repo, those images simply do not exist (!).

The output in VS shows:

========== Pulling Images ==========
Pulling missing Docker images. To cancel this download, close the command prompt window. To disable image auto-pull, see Tools > Options > Container Tools.
docker pull microsoft/aspnetcore:2.1
docker pull failed

The closest images I found are:

microsoft/aspnetcore:2.1.0-preview1
microsoft/aspnetcore-build:2.1.300-preview1

and the app works, BUT there is another problem: while debugging in VS, the debugger doesn't hit any breakpoints (because PDB symbols are not loaded, I don't know why that happens).

Everything I just described, works when creating a new ASP.NET Core 2.0 project.

1 Comment

Same boat here.

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.