Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I Run a dotnet app which is hosted on IIS in a docker container?

I have developed a web application using asp dotnet and currently I have it running on IIS is there anyway I can run the same app in a docker container,

I am relatively new to Docker and I have played around a bit and I am familiar with docker compose , so I was wondering if I can (dockerize) the application that I have developed.

My Dockerfile now looks like:

#Making a dotnet container
FROM microsoft/dotnet:latest

#Make a directory
WORKDIR /app

#copy dll files and other dependencies
COPY . /app

#dotnet run should run the app
ENTRYPOINT ["DOTNET","RUN"]

From what I understand this makes a directory inside my dotnet container and copies the files in the current folder and the app will run on dotnet run

like image 566
User1436 Avatar asked Sep 08 '16 15:09

User1436


People also ask

How do I run a docker container from a DotNet project?

You need a .NET Core app that the Docker container will run. Open your terminal, create a working folder if you haven't already, and enter it. In the working folder, run the following command to create a new project in a subdirectory named app: dotnet new console -o App -n NetCore.Docker Your folder tree will look like the following:

Can I run a web application in a docker container?

February 27th, 2019 In this post, App Dev Managers Anand Shuklaand Sash Kavalaparambil provide step by step instruction to run a .NET Core Web Application in Docker container using Docker Desktop for Windows.

How do I run an app from a DotNet container?

#Making a dotnet container FROM microsoft/dotnet:latest #Make a directory WORKDIR /app #copy dll files and other dependencies COPY . /app #dotnet run should run the app ENTRYPOINT ["DOTNET","RUN"] From what I understand this makes a directory inside my dotnet container and copies the files in the current folder and the app will run on dotnet run

What is the use of a docker container?

Docker is a containerization service, used for running applications in isolated environments packaged with all the dependencies and code it needs to function. It can run all kinds of applications, including .NET-based programs using Microsoft-provided runtime images. Microsoft provides prebuilt base images for running .NET applications.


1 Answers

You need to change a little your Dockerfile, try this:

#Making a dotnet container
FROM microsoft/iis

SHELL ["powershell"]

RUN Install-WindowsFeature NET-Framework-45-ASPNET ; \  
    Install-WindowsFeature Web-Asp-Net45

RUN Remove-WebSite -Name 'Default Web Site'  
RUN New-Website -Name 'app' -Port 80 \  
    -PhysicalPath 'c:\app' -ApplicationPool '.NET v4.5'

#copy dll files and other dependencies
COPY app app

#dotnet run should run the app
CMD ["ping", "-t", "localhost"]  

Test it

docker build -t app .  
docker run --name app -d -p 80:80 app
docker inspect --format="{{.NetworkSettings.Networks.nat.IPAddress}}" app

It will give you an ip just test it in your browser.

More information: Run IIS + ASP.NET on Windows 10 with Docker

like image 117
Carlos Rafael Ramirez Avatar answered Oct 27 '22 01:10

Carlos Rafael Ramirez