unable to send request to .net core app hosted with docker












1















I have create default VS2017 webAPI project with docker support for Linux.
When i had try to build image I met problem like "unable to find .../docker-buildxxxx/" , to solve it i moved dockerfile on one level up, where is *.sln and .dockerignore file are.



I had successfully build and run that image, but i have no luck to take some request into container. I use -p host_port:container_port in all possible combinations, but it is useless.



FYI: without docker it works fine. (dotnet test.dll)



Can you provide some point where i have to research or can you provide exact solution ?



docker version



Client: Docker Engine - Community
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:47:51 2018
OS/Arch: windows/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:52:55 2018
OS/Arch: linux/amd64
Experimental: false


docker run -t service --port 8080:80 --name myfirst_container



warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {71f5b198-2cbb-45ba-a7fc-a36df9f8b985} may be persisted to storage in unencrypted form.

Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.


DOCKERFILE



FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["test/test.csproj", "test/"]
RUN dotnet restore "test/test.csproj"
COPY . .
WORKDIR "/src/test"
RUN dotnet build "test.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "test.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "test.dll"]









share|improve this question

























  • Can you include your Dockerfile into your question?

    – ug_
    Nov 20 '18 at 0:12











  • @ug_ done. It is auto generated dockerfile by VS.

    – Vadim Bugaiov
    Nov 20 '18 at 8:57
















1















I have create default VS2017 webAPI project with docker support for Linux.
When i had try to build image I met problem like "unable to find .../docker-buildxxxx/" , to solve it i moved dockerfile on one level up, where is *.sln and .dockerignore file are.



I had successfully build and run that image, but i have no luck to take some request into container. I use -p host_port:container_port in all possible combinations, but it is useless.



FYI: without docker it works fine. (dotnet test.dll)



Can you provide some point where i have to research or can you provide exact solution ?



docker version



Client: Docker Engine - Community
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:47:51 2018
OS/Arch: windows/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:52:55 2018
OS/Arch: linux/amd64
Experimental: false


docker run -t service --port 8080:80 --name myfirst_container



warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {71f5b198-2cbb-45ba-a7fc-a36df9f8b985} may be persisted to storage in unencrypted form.

Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.


DOCKERFILE



FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["test/test.csproj", "test/"]
RUN dotnet restore "test/test.csproj"
COPY . .
WORKDIR "/src/test"
RUN dotnet build "test.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "test.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "test.dll"]









share|improve this question

























  • Can you include your Dockerfile into your question?

    – ug_
    Nov 20 '18 at 0:12











  • @ug_ done. It is auto generated dockerfile by VS.

    – Vadim Bugaiov
    Nov 20 '18 at 8:57














1












1








1








I have create default VS2017 webAPI project with docker support for Linux.
When i had try to build image I met problem like "unable to find .../docker-buildxxxx/" , to solve it i moved dockerfile on one level up, where is *.sln and .dockerignore file are.



I had successfully build and run that image, but i have no luck to take some request into container. I use -p host_port:container_port in all possible combinations, but it is useless.



FYI: without docker it works fine. (dotnet test.dll)



Can you provide some point where i have to research or can you provide exact solution ?



docker version



Client: Docker Engine - Community
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:47:51 2018
OS/Arch: windows/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:52:55 2018
OS/Arch: linux/amd64
Experimental: false


docker run -t service --port 8080:80 --name myfirst_container



warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {71f5b198-2cbb-45ba-a7fc-a36df9f8b985} may be persisted to storage in unencrypted form.

Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.


DOCKERFILE



FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["test/test.csproj", "test/"]
RUN dotnet restore "test/test.csproj"
COPY . .
WORKDIR "/src/test"
RUN dotnet build "test.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "test.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "test.dll"]









share|improve this question
















I have create default VS2017 webAPI project with docker support for Linux.
When i had try to build image I met problem like "unable to find .../docker-buildxxxx/" , to solve it i moved dockerfile on one level up, where is *.sln and .dockerignore file are.



I had successfully build and run that image, but i have no luck to take some request into container. I use -p host_port:container_port in all possible combinations, but it is useless.



FYI: without docker it works fine. (dotnet test.dll)



Can you provide some point where i have to research or can you provide exact solution ?



docker version



Client: Docker Engine - Community
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:47:51 2018
OS/Arch: windows/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:52:55 2018
OS/Arch: linux/amd64
Experimental: false


docker run -t service --port 8080:80 --name myfirst_container



warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {71f5b198-2cbb-45ba-a7fc-a36df9f8b985} may be persisted to storage in unencrypted form.

Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.


DOCKERFILE



FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["test/test.csproj", "test/"]
RUN dotnet restore "test/test.csproj"
COPY . .
WORKDIR "/src/test"
RUN dotnet build "test.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "test.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "test.dll"]






docker asp.net-core dockerfile






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 8:56







Vadim Bugaiov

















asked Nov 19 '18 at 23:36









Vadim BugaiovVadim Bugaiov

71211




71211













  • Can you include your Dockerfile into your question?

    – ug_
    Nov 20 '18 at 0:12











  • @ug_ done. It is auto generated dockerfile by VS.

    – Vadim Bugaiov
    Nov 20 '18 at 8:57



















  • Can you include your Dockerfile into your question?

    – ug_
    Nov 20 '18 at 0:12











  • @ug_ done. It is auto generated dockerfile by VS.

    – Vadim Bugaiov
    Nov 20 '18 at 8:57

















Can you include your Dockerfile into your question?

– ug_
Nov 20 '18 at 0:12





Can you include your Dockerfile into your question?

– ug_
Nov 20 '18 at 0:12













@ug_ done. It is auto generated dockerfile by VS.

– Vadim Bugaiov
Nov 20 '18 at 8:57





@ug_ done. It is auto generated dockerfile by VS.

– Vadim Bugaiov
Nov 20 '18 at 8:57












1 Answer
1






active

oldest

votes


















1














It was the two hardest nights in my life, but i get a solution.



Problem was caused by Visual studio, it generate wrong dockerfile.



Fixed dockerfile



FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY test/*.csproj ./test/
RUN dotnet restore

# copy everything else and build app
COPY test/. ./test/
WORKDIR /app/test
RUN dotnet publish -c Release -o out


FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime
WORKDIR /app
COPY --from=build /app/test/out ./
ENTRYPOINT ["dotnet", "test.dll"]


Solution came from here:



https://hub.docker.com/r/microsoft/dotnet-samples/



https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/Dockerfile






share|improve this answer
























  • I think the problem wasnt that it generated the wrong docker file but that you moved it one directory up. It was copying . . so the entire solution. You had it copy only the one project causing unintended side effects. IMO you should keep the docker file at the location it was generated and modify it to your needs. Thanks for posting your solution back tho!

    – ug_
    Nov 21 '18 at 22:07













  • With generated dockerfile, docker even does not build an image.

    – Vadim Bugaiov
    Nov 22 '18 at 14:50











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384194%2funable-to-send-request-to-net-core-app-hosted-with-docker%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














It was the two hardest nights in my life, but i get a solution.



Problem was caused by Visual studio, it generate wrong dockerfile.



Fixed dockerfile



FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY test/*.csproj ./test/
RUN dotnet restore

# copy everything else and build app
COPY test/. ./test/
WORKDIR /app/test
RUN dotnet publish -c Release -o out


FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime
WORKDIR /app
COPY --from=build /app/test/out ./
ENTRYPOINT ["dotnet", "test.dll"]


Solution came from here:



https://hub.docker.com/r/microsoft/dotnet-samples/



https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/Dockerfile






share|improve this answer
























  • I think the problem wasnt that it generated the wrong docker file but that you moved it one directory up. It was copying . . so the entire solution. You had it copy only the one project causing unintended side effects. IMO you should keep the docker file at the location it was generated and modify it to your needs. Thanks for posting your solution back tho!

    – ug_
    Nov 21 '18 at 22:07













  • With generated dockerfile, docker even does not build an image.

    – Vadim Bugaiov
    Nov 22 '18 at 14:50
















1














It was the two hardest nights in my life, but i get a solution.



Problem was caused by Visual studio, it generate wrong dockerfile.



Fixed dockerfile



FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY test/*.csproj ./test/
RUN dotnet restore

# copy everything else and build app
COPY test/. ./test/
WORKDIR /app/test
RUN dotnet publish -c Release -o out


FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime
WORKDIR /app
COPY --from=build /app/test/out ./
ENTRYPOINT ["dotnet", "test.dll"]


Solution came from here:



https://hub.docker.com/r/microsoft/dotnet-samples/



https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/Dockerfile






share|improve this answer
























  • I think the problem wasnt that it generated the wrong docker file but that you moved it one directory up. It was copying . . so the entire solution. You had it copy only the one project causing unintended side effects. IMO you should keep the docker file at the location it was generated and modify it to your needs. Thanks for posting your solution back tho!

    – ug_
    Nov 21 '18 at 22:07













  • With generated dockerfile, docker even does not build an image.

    – Vadim Bugaiov
    Nov 22 '18 at 14:50














1












1








1







It was the two hardest nights in my life, but i get a solution.



Problem was caused by Visual studio, it generate wrong dockerfile.



Fixed dockerfile



FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY test/*.csproj ./test/
RUN dotnet restore

# copy everything else and build app
COPY test/. ./test/
WORKDIR /app/test
RUN dotnet publish -c Release -o out


FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime
WORKDIR /app
COPY --from=build /app/test/out ./
ENTRYPOINT ["dotnet", "test.dll"]


Solution came from here:



https://hub.docker.com/r/microsoft/dotnet-samples/



https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/Dockerfile






share|improve this answer













It was the two hardest nights in my life, but i get a solution.



Problem was caused by Visual studio, it generate wrong dockerfile.



Fixed dockerfile



FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY test/*.csproj ./test/
RUN dotnet restore

# copy everything else and build app
COPY test/. ./test/
WORKDIR /app/test
RUN dotnet publish -c Release -o out


FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime
WORKDIR /app
COPY --from=build /app/test/out ./
ENTRYPOINT ["dotnet", "test.dll"]


Solution came from here:



https://hub.docker.com/r/microsoft/dotnet-samples/



https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/Dockerfile







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 0:09









Vadim BugaiovVadim Bugaiov

71211




71211













  • I think the problem wasnt that it generated the wrong docker file but that you moved it one directory up. It was copying . . so the entire solution. You had it copy only the one project causing unintended side effects. IMO you should keep the docker file at the location it was generated and modify it to your needs. Thanks for posting your solution back tho!

    – ug_
    Nov 21 '18 at 22:07













  • With generated dockerfile, docker even does not build an image.

    – Vadim Bugaiov
    Nov 22 '18 at 14:50



















  • I think the problem wasnt that it generated the wrong docker file but that you moved it one directory up. It was copying . . so the entire solution. You had it copy only the one project causing unintended side effects. IMO you should keep the docker file at the location it was generated and modify it to your needs. Thanks for posting your solution back tho!

    – ug_
    Nov 21 '18 at 22:07













  • With generated dockerfile, docker even does not build an image.

    – Vadim Bugaiov
    Nov 22 '18 at 14:50

















I think the problem wasnt that it generated the wrong docker file but that you moved it one directory up. It was copying . . so the entire solution. You had it copy only the one project causing unintended side effects. IMO you should keep the docker file at the location it was generated and modify it to your needs. Thanks for posting your solution back tho!

– ug_
Nov 21 '18 at 22:07







I think the problem wasnt that it generated the wrong docker file but that you moved it one directory up. It was copying . . so the entire solution. You had it copy only the one project causing unintended side effects. IMO you should keep the docker file at the location it was generated and modify it to your needs. Thanks for posting your solution back tho!

– ug_
Nov 21 '18 at 22:07















With generated dockerfile, docker even does not build an image.

– Vadim Bugaiov
Nov 22 '18 at 14:50





With generated dockerfile, docker even does not build an image.

– Vadim Bugaiov
Nov 22 '18 at 14:50




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384194%2funable-to-send-request-to-net-core-app-hosted-with-docker%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini