0

I am attempting to "Lift and Shift" a legacy web service (and the website used to administer it) that was written using MVC 3. I have used the visual studio "add -> docker support" feature and I am getting my website in a container and the website will run properly if I manually connect to the running container and install MVC 3. I would much rather have MVC 3 installed when the container is built.

The dockerfile looks like this:

# escape=` (backtick)

FROM microsoft/aspnet:4.7.1-windowsservercore-1709
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .
RUN  C:\inetpub\wwwroot\AspNetMVC3Setup.exe /q

The last line of the dockerfile is the thing that does not work. I have tried several variations but the result is always some type of path not found error.

Examples of other attempted syntax:

RUN ["C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]
RUN ["powershell.exe", "C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]
RUN ["powershell.exe", ".\AspNetMVC3Setup.exe", "/q"]
RUN [".\AspNetMVC3Setup.exe", "/q"]
RUN AspNetMVC3Setup.exe /q

The paths and file names are correct when I connect to the running container but is it possible that during the build the files aren't really there yet?

How might I run the MVC install as part of the container build?

Error examples:

13>Step 5/5 : RUN  C:\inetpub\wwwroot\AspNetMVC3Setup.exe /q
13> ---> Running in 3b7e8c30f2e0
13>[91mC:\inetpub\wwwroot\AspNetMVC3Setup.exe : The term
13>[0m[91m'C:\inetpub\wwwroot\AspNetMVC3Setup.exe' is not recognized as the name of a
13>cmdlet, function, script file, or operable program. Check the spelling of the
13>[0m[91mname, or if a path was included, verify that the path is correct and try again.
13>[0m[91mAt line:1 char:76
13>[0m[91m+ ... rence = 'SilentlyContinue'; C:\inetpub\wwwroot\AspNetMVC3Setup.exe /q
13>[0m[91m+                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13>    + CategoryInfo          : ObjectNotFound: (C:\inetpub\wwwroot\AspNetMVC3Se
13>   tup.exe:String) [], ParentContainsErrorRecordException
13>    + FullyQualifiedErrorId : CommandNotFoundException


13>Step 5/5 : RUN ["C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]
13> ---> Running in 7322410daf93
13>[91mAt line:1 char:77
13>[0m[91m+ ... ference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; [C:\inetp ...
13>+                                                                  ~
13>[0m[91mMissing ] at end of attribute or type literal.
13>[0m[91mAt line:1 char:78
13>+ ... ce = 'SilentlyContinue'; [C:\inetpub\wwwroot\AspNetMVC3Setup.exe, /q]
13>[0m[91m+                                
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13>Unexpected token ':\inetpub\wwwroot\AspNetMVC3Setup.exe' in expression or
13>[0m[91mstatement.
13>At line:1 char:115
13>+ ... ce = 'SilentlyContinue'; [C:\inetpub\wwwroot\AspNetMVC3Setup.exe, /q]
13>+                                                                     ~
13>Missing argument in parameter list.
13>    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx
13>   ception
13>[0m[91m    + FullyQualifiedErrorId : EndSquareBracketExpectedAtEndOfAttribute
13>
13>Service 'adminmanagement' failed to build: The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; ["C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]' returned a non-zero code: 1
13>[0m


13>Step 5/5 : RUN ["powershell.exe", "C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]
13> ---> Running in 44113a1005d2
13>[91mUnable to find type [powershell.exe,C:\inetpub\wwwroot\AspNetMVC3Setup.exe,
13>/q]. Details: The given assembly name or codebase was invalid. (Exception from
13>HRESULT: 0x80131047)
13>At line:1 char:76
13>[0m[91m+ ... yContinue'; [powershell.exe, C:\inetpub\wwwroot\AspNetMVC3Setup.exe,  ...
13>[0m[91m+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13>    + CategoryInfo          : InvalidOperation: (powershell.exe,...C3Setup.exe
13>   , /q:TypeName) [], ParentContainsErrorRecordException
13>[0m[91m    + FullyQualifiedErrorId : TypeNotFoundWithMessage
13>[0m[91m
13>Service 'adminmanagement' failed to build: The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; ["powershell.exe", "C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]' returned a non-zero code: 1
 13>[0m
S.Quid
  • 3
  • 3
  • what output do you get for `Run` statement during build? – Gregory Suvalian Jun 05 '18 at 22:30
  • Could the ` (backtick) attribute be failing? Possibly the \'s are being treated as escape characters? – S.Quid Jun 05 '18 at 23:03
  • Where is in your dockerfile are you adding this executable to image? – Gregory Suvalian Jun 05 '18 at 23:09
  • The exe was added to the project and is copied to the output, so the COPY line is taking care of that. The file is there when I connect to the running container. I'd be happy to change this, but attempts at copying that file separately to be 100% sure it was already there have resulted in equally problematic errors. Since I used the visual studio feature, docker is now using strange temp folders and the paths don't make sense to me (they don't seem relative to the location of the dockerfile). – S.Quid Jun 05 '18 at 23:11
  • I suggest write a clean docker file without VS mumbo jumbo. VS is Frontpage of modern age where they try to simplify things but instead create a monster – Gregory Suvalian Jun 05 '18 at 23:18
  • Yeah, I had tried to do that, but can't seem to get that working (it worked a few days ago). I'm wondering if VS changed the way docker is behaving. As an example, this worked before and no longer works now: COPY ./bin/Release/PublishOutput/ /inetpub/wwwroot (instead of the $(varable) stuff). – S.Quid Jun 05 '18 at 23:23
  • This has given me the motivation to try getting the non-VS way to function again. I'll try some things like removing and re-installing docker and see what happens. – S.Quid Jun 05 '18 at 23:25
  • I don't think it's docker config related, just crap that VS put in – Gregory Suvalian Jun 05 '18 at 23:27

1 Answers1

0

I could not get this to work within Visual Studio but by using a very similar dockerfile, a change to the .dockerignore and by invoking docker directly from PowerShell, I was able to have MVC 3 installed during the container build.

Dockerfile:

# escape=` (backtick)

FROM microsoft/aspnet:4.7.1-windowsservercore-1709
COPY ./bin/Release/Publish/ /inetpub/wwwroot
RUN C:\inetpub\wwwroot\AspNetMVC3Setup.exe /q

.dockerignore file:

*
!./bin/Release/Publish/*
!obj\Docker\publish\*
!obj\Docker\empty\

The change to the .dockerignore was to add the following:

!./bin/Release/Publish/*

Docker commands:

docker build -t [imagename] .
docker run -d --name [containername] [imagename]
S.Quid
  • 3
  • 3