Can I further reduce dependency on docker images to run by asp.net web api application on docker container












1















I followed https://github.com/Microsoft/dotnet-framework-docker link to build my sample ASP.NET Web API application build on top on .net 4.6.1 framework.



Here is my docker file:



FROM microsoft/dotnet-framework:4.7.2-sdk AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY TestWebAPI/*.csproj ./TestWebAPI/
COPY TestWebAPI/*.config ./TestWebAPI/
RUN nuget restore

# copy everything else and build app
COPY TestWebAPI/. ./TestWebAPI/
WORKDIR /app/TestWebAPI
RUN msbuild /p:Configuration=Release


FROM microsoft/aspnet:4.7.2 AS runtime
WORKDIR /inetpub/wwwroot
COPY --from=build /app/TestWebAPI/. ./


To run the script I executed following commands:



docker image build --tag testwebapi --file .Dockerfile .

docker container run --detach --publish 80 testwebapi


The script is working fine and I am able to run my application.



Questions:





  1. I am using dotnet-framework:4.7.2-sdk image to build & aspnet:4.7.2 image to run the application. I looked at the aspnet image and it contains "Windows Server Core as the base OS, IIS 10 as Web Server, .NET Framework (multiple versions available),.NET Extensibility for IIS". In this case do I still need dotnet-framework:4.7.2-sdk image ?



    enter image description here



  2. I don't think the script is using IIS as the web server. How can I use IIS to host this application?











share|improve this question























  • You need the SDK to compile it, but not to run it.

    – SLaks
    Jan 1 at 22:58











  • @SLaks: I could be wrong but the aspnet image also contains the .net framework. I assume it should also have MSBuild.exe to build the application.

    – OpenStack
    Jan 1 at 23:02
















1















I followed https://github.com/Microsoft/dotnet-framework-docker link to build my sample ASP.NET Web API application build on top on .net 4.6.1 framework.



Here is my docker file:



FROM microsoft/dotnet-framework:4.7.2-sdk AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY TestWebAPI/*.csproj ./TestWebAPI/
COPY TestWebAPI/*.config ./TestWebAPI/
RUN nuget restore

# copy everything else and build app
COPY TestWebAPI/. ./TestWebAPI/
WORKDIR /app/TestWebAPI
RUN msbuild /p:Configuration=Release


FROM microsoft/aspnet:4.7.2 AS runtime
WORKDIR /inetpub/wwwroot
COPY --from=build /app/TestWebAPI/. ./


To run the script I executed following commands:



docker image build --tag testwebapi --file .Dockerfile .

docker container run --detach --publish 80 testwebapi


The script is working fine and I am able to run my application.



Questions:





  1. I am using dotnet-framework:4.7.2-sdk image to build & aspnet:4.7.2 image to run the application. I looked at the aspnet image and it contains "Windows Server Core as the base OS, IIS 10 as Web Server, .NET Framework (multiple versions available),.NET Extensibility for IIS". In this case do I still need dotnet-framework:4.7.2-sdk image ?



    enter image description here



  2. I don't think the script is using IIS as the web server. How can I use IIS to host this application?











share|improve this question























  • You need the SDK to compile it, but not to run it.

    – SLaks
    Jan 1 at 22:58











  • @SLaks: I could be wrong but the aspnet image also contains the .net framework. I assume it should also have MSBuild.exe to build the application.

    – OpenStack
    Jan 1 at 23:02














1












1








1








I followed https://github.com/Microsoft/dotnet-framework-docker link to build my sample ASP.NET Web API application build on top on .net 4.6.1 framework.



Here is my docker file:



FROM microsoft/dotnet-framework:4.7.2-sdk AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY TestWebAPI/*.csproj ./TestWebAPI/
COPY TestWebAPI/*.config ./TestWebAPI/
RUN nuget restore

# copy everything else and build app
COPY TestWebAPI/. ./TestWebAPI/
WORKDIR /app/TestWebAPI
RUN msbuild /p:Configuration=Release


FROM microsoft/aspnet:4.7.2 AS runtime
WORKDIR /inetpub/wwwroot
COPY --from=build /app/TestWebAPI/. ./


To run the script I executed following commands:



docker image build --tag testwebapi --file .Dockerfile .

docker container run --detach --publish 80 testwebapi


The script is working fine and I am able to run my application.



Questions:





  1. I am using dotnet-framework:4.7.2-sdk image to build & aspnet:4.7.2 image to run the application. I looked at the aspnet image and it contains "Windows Server Core as the base OS, IIS 10 as Web Server, .NET Framework (multiple versions available),.NET Extensibility for IIS". In this case do I still need dotnet-framework:4.7.2-sdk image ?



    enter image description here



  2. I don't think the script is using IIS as the web server. How can I use IIS to host this application?











share|improve this question














I followed https://github.com/Microsoft/dotnet-framework-docker link to build my sample ASP.NET Web API application build on top on .net 4.6.1 framework.



Here is my docker file:



FROM microsoft/dotnet-framework:4.7.2-sdk AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY TestWebAPI/*.csproj ./TestWebAPI/
COPY TestWebAPI/*.config ./TestWebAPI/
RUN nuget restore

# copy everything else and build app
COPY TestWebAPI/. ./TestWebAPI/
WORKDIR /app/TestWebAPI
RUN msbuild /p:Configuration=Release


FROM microsoft/aspnet:4.7.2 AS runtime
WORKDIR /inetpub/wwwroot
COPY --from=build /app/TestWebAPI/. ./


To run the script I executed following commands:



docker image build --tag testwebapi --file .Dockerfile .

docker container run --detach --publish 80 testwebapi


The script is working fine and I am able to run my application.



Questions:





  1. I am using dotnet-framework:4.7.2-sdk image to build & aspnet:4.7.2 image to run the application. I looked at the aspnet image and it contains "Windows Server Core as the base OS, IIS 10 as Web Server, .NET Framework (multiple versions available),.NET Extensibility for IIS". In this case do I still need dotnet-framework:4.7.2-sdk image ?



    enter image description here



  2. I don't think the script is using IIS as the web server. How can I use IIS to host this application?








c# asp.net docker asp.net-web-api containers






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 1 at 22:53









OpenStackOpenStack

75131030




75131030













  • You need the SDK to compile it, but not to run it.

    – SLaks
    Jan 1 at 22:58











  • @SLaks: I could be wrong but the aspnet image also contains the .net framework. I assume it should also have MSBuild.exe to build the application.

    – OpenStack
    Jan 1 at 23:02



















  • You need the SDK to compile it, but not to run it.

    – SLaks
    Jan 1 at 22:58











  • @SLaks: I could be wrong but the aspnet image also contains the .net framework. I assume it should also have MSBuild.exe to build the application.

    – OpenStack
    Jan 1 at 23:02

















You need the SDK to compile it, but not to run it.

– SLaks
Jan 1 at 22:58





You need the SDK to compile it, but not to run it.

– SLaks
Jan 1 at 22:58













@SLaks: I could be wrong but the aspnet image also contains the .net framework. I assume it should also have MSBuild.exe to build the application.

– OpenStack
Jan 1 at 23:02





@SLaks: I could be wrong but the aspnet image also contains the .net framework. I assume it should also have MSBuild.exe to build the application.

– OpenStack
Jan 1 at 23:02












1 Answer
1






active

oldest

votes


















0














First, note that the sdk base image is not actually included in your final image, only the runtime image is. There are two FROM lines in your Dockerfile:



FROM microsoft/dotnet-framework:4.7.2-sdk AS build
...
FROM microsoft/aspnet:4.7.2 AS runtime


This creates a multi-stage build. Only the base image of the second (last) stage, which is the runtime image, will be included in your image.



For what's included in the sdk image beyond the .NET Framework itself, take a look at its Dockerfile and you'll spot a few things you definitely won't need on your production servers, such as NuGet CLI, VS Test Agent etc.






share|improve this answer



















  • 1





    I looked at the other dockerfile mentioned in your answer. Looking at this dockerfile, it looks like my dockerfile is already pretty lean and this container can run in production. Am i missing something? Also with Multistage build, I don't have to worry about sdk image being added to my container.

    – OpenStack
    Jan 2 at 4:03











  • Can you answer my second question, how can i Utilize IIS ?

    – OpenStack
    Jan 2 at 4:03











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%2f53999565%2fcan-i-further-reduce-dependency-on-docker-images-to-run-by-asp-net-web-api-appli%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









0














First, note that the sdk base image is not actually included in your final image, only the runtime image is. There are two FROM lines in your Dockerfile:



FROM microsoft/dotnet-framework:4.7.2-sdk AS build
...
FROM microsoft/aspnet:4.7.2 AS runtime


This creates a multi-stage build. Only the base image of the second (last) stage, which is the runtime image, will be included in your image.



For what's included in the sdk image beyond the .NET Framework itself, take a look at its Dockerfile and you'll spot a few things you definitely won't need on your production servers, such as NuGet CLI, VS Test Agent etc.






share|improve this answer



















  • 1





    I looked at the other dockerfile mentioned in your answer. Looking at this dockerfile, it looks like my dockerfile is already pretty lean and this container can run in production. Am i missing something? Also with Multistage build, I don't have to worry about sdk image being added to my container.

    – OpenStack
    Jan 2 at 4:03











  • Can you answer my second question, how can i Utilize IIS ?

    – OpenStack
    Jan 2 at 4:03
















0














First, note that the sdk base image is not actually included in your final image, only the runtime image is. There are two FROM lines in your Dockerfile:



FROM microsoft/dotnet-framework:4.7.2-sdk AS build
...
FROM microsoft/aspnet:4.7.2 AS runtime


This creates a multi-stage build. Only the base image of the second (last) stage, which is the runtime image, will be included in your image.



For what's included in the sdk image beyond the .NET Framework itself, take a look at its Dockerfile and you'll spot a few things you definitely won't need on your production servers, such as NuGet CLI, VS Test Agent etc.






share|improve this answer



















  • 1





    I looked at the other dockerfile mentioned in your answer. Looking at this dockerfile, it looks like my dockerfile is already pretty lean and this container can run in production. Am i missing something? Also with Multistage build, I don't have to worry about sdk image being added to my container.

    – OpenStack
    Jan 2 at 4:03











  • Can you answer my second question, how can i Utilize IIS ?

    – OpenStack
    Jan 2 at 4:03














0












0








0







First, note that the sdk base image is not actually included in your final image, only the runtime image is. There are two FROM lines in your Dockerfile:



FROM microsoft/dotnet-framework:4.7.2-sdk AS build
...
FROM microsoft/aspnet:4.7.2 AS runtime


This creates a multi-stage build. Only the base image of the second (last) stage, which is the runtime image, will be included in your image.



For what's included in the sdk image beyond the .NET Framework itself, take a look at its Dockerfile and you'll spot a few things you definitely won't need on your production servers, such as NuGet CLI, VS Test Agent etc.






share|improve this answer













First, note that the sdk base image is not actually included in your final image, only the runtime image is. There are two FROM lines in your Dockerfile:



FROM microsoft/dotnet-framework:4.7.2-sdk AS build
...
FROM microsoft/aspnet:4.7.2 AS runtime


This creates a multi-stage build. Only the base image of the second (last) stage, which is the runtime image, will be included in your image.



For what's included in the sdk image beyond the .NET Framework itself, take a look at its Dockerfile and you'll spot a few things you definitely won't need on your production servers, such as NuGet CLI, VS Test Agent etc.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 2 at 3:06









MaxMax

3,39883651




3,39883651








  • 1





    I looked at the other dockerfile mentioned in your answer. Looking at this dockerfile, it looks like my dockerfile is already pretty lean and this container can run in production. Am i missing something? Also with Multistage build, I don't have to worry about sdk image being added to my container.

    – OpenStack
    Jan 2 at 4:03











  • Can you answer my second question, how can i Utilize IIS ?

    – OpenStack
    Jan 2 at 4:03














  • 1





    I looked at the other dockerfile mentioned in your answer. Looking at this dockerfile, it looks like my dockerfile is already pretty lean and this container can run in production. Am i missing something? Also with Multistage build, I don't have to worry about sdk image being added to my container.

    – OpenStack
    Jan 2 at 4:03











  • Can you answer my second question, how can i Utilize IIS ?

    – OpenStack
    Jan 2 at 4:03








1




1





I looked at the other dockerfile mentioned in your answer. Looking at this dockerfile, it looks like my dockerfile is already pretty lean and this container can run in production. Am i missing something? Also with Multistage build, I don't have to worry about sdk image being added to my container.

– OpenStack
Jan 2 at 4:03





I looked at the other dockerfile mentioned in your answer. Looking at this dockerfile, it looks like my dockerfile is already pretty lean and this container can run in production. Am i missing something? Also with Multistage build, I don't have to worry about sdk image being added to my container.

– OpenStack
Jan 2 at 4:03













Can you answer my second question, how can i Utilize IIS ?

– OpenStack
Jan 2 at 4:03





Can you answer my second question, how can i Utilize IIS ?

– OpenStack
Jan 2 at 4:03




















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%2f53999565%2fcan-i-further-reduce-dependency-on-docker-images-to-run-by-asp-net-web-api-appli%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







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement