docker-archive / communitytools-image2docker-win

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing Run commands and Windows commands not running

jontreynes opened this issue · comments

ConvertTo-Dockerfile is creating an insufficient Dockerfile for me from my windows server 2016 vhdx. When I try extracting an ASP.net app hosted in IIS, it does not supply the standard line "RUN Add-WindowsFeature Web-server, Net-Framework-45-ASPNET, Web-Asp-Net45"

Side note:
Also, my "RUN Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationDevelopment,IIS-ApplicationInit,..." is receiving an error message saying,"Enable-WindowsOptionalFeature : One or several parent features are disabled so
current feature can not be enabled."

Is my vhdx not reaching a certain requirement?

Some more info.
My vm had aspnet 3.5 and 4.5 installed which probably isn't best practice.
The asp.net Application I wanted to extract required 4.5. However, the ConvertToDockerfile prepped this as the base image FROM microsoft/aspnet:3.5-windowsservercore-10.0.14393.1066 and did not consider 4.5

Thanks for that - can you try running your ConvertToDockerfile command with an -ArtifactParam argument, so it only extracts the .NET 4.5 web app you're interested in? The IIS docs have examples for that.

On the wider issue, the fix for this isn't very nice. If you have 3.5 in the source then we need to use aspnet:3.5 as the base image, because you can't install 3.5 with any of the standard Windows Server images. So then we'd need to start from aspnet:3.5 and install 4.5 on top. Possible, but not a great result.

Hey! Thanks for a speedy reply @sixeyed . I did run -ArtifactParam IIS. And yes... that does make sense. I guess image2docker is not smart enough to tell which IIS web app is running 3.5 and which is running 4.5. Would be a nice feature to have...but not sure if there's many use cases for this yet. Something like
ConvertTo-Dockerfile -imagepath blahblah -outputpath blahblahblah -artifact IIS -artifactParam webapp -ArtifactDependsOn asp.net-4.5 would be nice.

Some manual editing got this to run as smooth as Steve Harvey's head


###escape=`
FROM microsoft/aspnet:3.5-windowsservercore-10.0.14393.1066

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

##disable DNS cache so container addresses always fetched from Docker
RUN Set-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord

RUN Remove-Website 'Default Web Site';

###COMMENTED OUT THIS -->> RUN Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationDevelopment,IIS-ApplicationInit,IIS-ASP,IIS-ASPNET,IIS-ASPNET45,IIS-BasicAuthentication,IIS-CertProvider,IIS-CGI,IIS-ClientCertificateMappingAuthentication,IIS-CommonHttpFeatures,IIS-CustomLogging,IIS-DefaultDocument,IIS-DigestAuthentication,IIS-DirectoryBrowsing,IIS-FTPExtensibility,IIS-FTPServer,IIS-FTPSvc,IIS-HealthAndDiagnostics,IIS-HttpCompressionDynamic,IIS-HttpCompressionStatic,IIS-HttpErrors,IIS-HttpLogging,IIS-HttpRedirect,IIS-HttpTracing,IIS-IISCertificateMappingAuthentication,IIS-IPSecurity,IIS-ISAPIExtensions,IIS-ISAPIFilter,IIS-LoggingLibraries,IIS-Metabase,IIS-NetFxExtensibility,IIS-NetFxExtensibility45,IIS-ODBCLogging,IIS-Performance,IIS-RequestFiltering,IIS-RequestMonitor,IIS-Security,IIS-ServerSideIncludes,IIS-StaticContent,IIS-URLAuthorization,IIS-WebDAV,IIS-WebServer,IIS-WebServerRole,IIS-WebSockets,IIS-WindowsAuthentication,NetFx4Extended-ASPNET45

#####I JUST ADDED THIS LINE#################################
RUN Add-WindowsFeature Web-server, Net-Framework-45-ASPNET, Web-Asp-Net45
########################################################

##Set up website: mywebapp
RUN New-Item -Path 'C:\inetpub\wwwroot\mywebapp' -Type Directory -Force;

RUN New-Website -Name 'mywebapp' -PhysicalPath 'C:\inetpub\wwwroot\mywebapp' -Port 8080 -Force;

EXPOSE 8080

COPY ["mywebapp", "/inetpub/wwwroot/mywebapp"]


or you could do this...
replace the base image with microsoft/aspnet:windowsservercore-10.0.14393.1066 and leave it all the same :)

Hope this helps anyone!

I'm going to close this. @sixeyed would it make sense to search for versions in reverse order? That way we'd always match the latest version instead of the oldest version.