Docker Community Forums

Share and learn in the Docker community.

Use msdeploy to build image


#1

New to Docker, please be gentle

I am running Docker for Windows (version 18.09) on Windows Server 2016. I would like to build an image to run a .NET Framework app. Visual Studio 2015 produced the following artifacts

  1. myapp.deploy.cmd (.bat)
  2. myapp.SetParameters.xml (configuration parameters)
  3. myapp.zip (application binaries, DLLs, etc)

Our current deployment procedure on a VM involves running the CMD file which invokes MSDEPLOY with these artifacts as described here.

In order to dockerize this application,

  1. Which base image should I use, hopefully one that has msdeploy in it already? I see several pre-built images here but not sure which one to use.
  2. How should I write these steps in the Dockerfile to build the image?
  3. How can I expose Port 80 to access the app running in the container?

Thanks


(Artisticcheese) #2

Don’t use any prebuilt images unless they are provided by well established player which will rebuild those monthly. If I was you I would just start with plain dotnetframework image. Install mspdeploy and then run it inside dockerfile. But ultimately the best thing to do is to decouple all your artifacts from msdeploy to actual stuff which is required and install only those things since all msdeploy is doing is packaging your software. If you rely on msdeploy your image will be bigger and still will hide all the details about your app, while one of the benefits of docker in general is that Dockerfile itself provides documentation about how your application is built from ground up.


#3

I see your point. OK I started with this

FROM mcr.microsoft.com/dotnet/framework/aspnet
SHELL [“powershell”]

COPY ./* c:/inetpub/wwwroot/

RUN New-Website -Name ‘foo’ -Port 80 -PhysicalPath c:/inetpub/wwwroot

RUN Set-WebConfigurationProperty -filter /system.WebServer/security/authentication/AnonymousAuthentication -name enabled -value true -location foo
RUN Set-WebConfigurationProperty -filter /system.WebServer/security/authentication/windowsAuthentication -name enabled -value false -location foo

EXPOSE 80

where the current folder contains a Dockerfile and the IIS .NET app folder from a functioning IIS VM

The image was built successfully but no matter which URL I acess e.g. /default.aspx, /picture.jpg, / I get a 404

What is the default location for site and how does one troubleshoot in Docker?

Thanks


(Artisticcheese) #4

Once you have container running go into container via docker exec -it <containerid> powershell and after that you shall administer application just as you would on server core image from command line. Also there is already website existent in that base image, so find where it points to and copy files there into inetpub folder.


#5

I’m having trouble understanding your suggestion. Could you please do me a favor and fix my Dockerfile? Basically, I have a folder with a bunch of files and I want to put a site on it. Thanks


(Artisticcheese) #6
#escape = `
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2-windowsservercore-ltsc2019
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $verbosePreference='Continue';"]

RUN  Set-Content -Path "c:\inetpub\wwwroot\default.htm" -value 'heeeeellllloooo from Docker'

EXPOSE 80

chrome_2019-01-08_21-15-05


(Cdaf) #7

To deploy classic ASP.NET applications into docker images I use the Microsoft IIS image (mcr.microsoft.com/windows/servercore/iis) and install MSDeploy agent. Then I deploy the application knowing it will fail, when it does, correct the ACL and deploy again, which will be successful and then the image is ready for use.

Note: this is an “impure” container use case and you would be better to re-engineer as dotnet core with Kestrel, but it’s pragmatic.

you can reuse this script https://github.com/cdaf/windows/blob/master/automation/provisioning/WebDeploy.ps1 with argment ‘agent’

execute web deploy, when it fails use this one

and run the web deploy again