2

I'm having an issue with manually building and running a windows server core container with a legacy asp.net web application. From Visual Studio I can run the container with the auto-generated dockerfile/yml file.

I want to do a docker build and docker run powershell command using the dockerfile instead of with Visual Studio.

This is current yml file:

version: '3'

services:

  fulldotnetwebapplication:

    image: fulldotnetwebapplication

    build:

      context: .\FullDotNetWebApplication

      dockerfile: Dockerfile

This is the current dockerfile:

FROM microsoft/aspnet:4.7.1-windowsservercore-ltsc2016

ARG source

WORKDIR /inetpub/wwwroot

COPY ${source:-obj/Docker/publish} .

Let's say my ASP project is FullDotNetWebApplicationand it contains App_Data, Content, Controllers, etc folders plus Master/ASPX pages along with web/packages/config.

I tried this for my Dockerfile:

FROM microsoft/aspnet:4.7.1-windowsservercore-ltsc2016

WORKDIR /inetpub/wwwroot

COPY . . 

COPY ./bin ./bin

and am getting this error:

docker : COPY failed: GetFileAttributesEx \\?\C:\Windows\TEMP\docker-builder977521850\bin: The system cannot find the file specified.
At line:1 char:1
+ docker build -t fulldotnetwebapplication .
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (COPY failed: Ge...file specified.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

What should my docker file look like to deploy this application to IIS from Powershell? I'm not understanding what magic VS is doing to make this work? Is it building the application or some sort of deployment file being generated? Any examples I could be pointed to or sample Dockerfile's would be great.

CDspace
  • 2,639
  • 18
  • 30
  • 36
Tim B
  • 215
  • 1
  • 2
  • 12
  • These might help get you pointed in the right direction: https://blog.alexellis.io/run-iis-asp-net-on-windows-10-with-docker/ https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-images https://www.red-gate.com/simple-talk/sysadmin/virtualization/working-windows-containers-docker-running/ https://sarafian.github.io/2017/02/14/docker-windows-full-asp.net-application.html Hope that helps – trebleCode Jan 19 '18 at 20:28
  • You have to build your application first before putting into container, you can use multistage .NET build process (https://blog.sixeyed.com/dockerizing-net-apps-with-microsofts-build-images-on-docker-hub/), then once your applicatin is built you put it into container like you mentiond above. The reason why you have that error is that you did not build your application – Gregory Suvalian Jan 19 '18 at 20:40

1 Answers1

0
${source:-obj/Docker/publish}

That is why you can run it in VS but not from PowerShell/CMD, VS injects the source part of that path, to map it to the special docker publish folder for the current project.

If up replace that with . ., that means copy everything recursively from my current executing directory (which is usually the same as the dockerfile location if you didn't specify the file manually) to the working directory in the container. As such, your attempt COPY ./bin ./bin is unnecessary, as the proceeding COPY . . will have already copied that directory (assuming it does actually exist)

Is it building the application or some sort of deployment file being generated?

The container is the unit of deployment, you cannot deploy a container to IIS, it must be run on a container Host. Docker will not build your solution either, before building the container you should build your solution, and then copy just the required output (which is what the VS source path is attempting to do).

It is possible to get your container workflow to also build your solution using a multi-stage container, where by you use a container with VS installed to build the project, then copy the output to another container for running it, but that is a fairly advanced setup that I wouldn't recommend if you can't even get normal build copying working.

CodedBeard
  • 862
  • 8
  • 19