简体   繁体   English

将ASP.Net应用程序部署到Window Server Core容器

[英]Deploy ASP.Net Application to Window Server Core Container

I'm having an issue with manually building and running a windows server core container with a legacy asp.net web application. 我在使用旧版asp.net Web应用程序手动构建和运行Windows Server核心容器时遇到问题。 From Visual Studio I can run the container with the auto-generated dockerfile/yml file. 从Visual Studio中,我可以使用自动生成的dockerfile / yml文件运行容器。

I want to do a docker build and docker run powershell command using the dockerfile instead of with Visual Studio. 我想使用dockerfile而不是Visual Studio进行docker build和docker run powershell命令。

This is current yml file: 这是当前的yml文件:

version: '3'

services:

  fulldotnetwebapplication:

    image: fulldotnetwebapplication

    build:

      context: .\FullDotNetWebApplication

      dockerfile: Dockerfile

This is the current dockerfile: 这是当前的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. 假设我的ASP项目是FullDotNetWebApplication,它包含App_Data,Content,Controllers等文件夹以及Master / ASPX页面以及web / packages / config。

I tried this for my Dockerfile: 我为我的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? 我的docker文件应如何从Powershell将此应用程序部署到IIS? I'm not understanding what magic VS is doing to make this work? 我不明白魔术VS在做什么以使它起作用? 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. 我可以指出的任何示例或示例Dockerfile都很棒。

${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. 因此,您可以在VS中运行它,但不能从PowerShell / CMD中运行它,VS会注入该路径的源部分,以将其映射到当前项目的特殊docker publish文件夹。

If up replace that with . . 如果up替换为. . . . , 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. ,这意味着将所有内容以递归方式从我当前的执行目录(如果未手动指定文件,通常与dockerfile位置相同)复制到容器中的工作目录。 As such, your attempt COPY ./bin ./bin is unnecessary, as the proceeding COPY . . 这样,您就不必进行COPY ./bin ./bin ,因为进行COPY . . 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. 容器是部署的单元,您不能将容器部署到IIS,它必须在容器主机上运行。 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). Docker也不会构建您的解决方案,在构建容器之前,您应该构建您的解决方案,然后仅复制所需的输出(这是VS源路径正在尝试执行的操作)。

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. 可以使容器工作流也使用多阶段容器来构建解决方案,在这种情况下,您可以使用安装了VS的容器来构建项目,然后将输出复制到另一个容器中以运行它,但这是相当合理的。如果您甚至无法正常进行构建复制,我将不建议您使用高级设置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将ASP.NET应用程序部署到Linux服务器上的Docker容器? - How to deploy asp.net application to docker container on Linux server? Asp.net 核心应用程序部署为 exe - Asp.net core application deploy as exe 将 ASP.NET Core 应用程序部署到 IIS - Deploy ASP.NET Core application to IIS 如何从在容器中运行的 ASP.NET 核心应用程序连接到具有集成安全性的 Windows 服务器上的 SQL 服务器 - How to connect from ASP.NET Core application running in a container to SQL Server on Windows Server with Integrated Security 如何将 ASP.NET 核心 web 应用程序部署到 ZAEA23489CE3AA9B6406EBB28E0CDA4016 上的 IIS 应用程序 - How to deploy ASP.NET core web application to IIS on Windows Server 2016 如何使用MS SQL Server数据库发布和部署Asp.net核心数据库优先应用程序 - How to publish and deploy an Asp.net Core Database first application with MS SQL Server Database ASP.NET Core Web 部署后应用程序403错误 - ASP.NET Core Web application 403 error after deploy IIS在ASP.NET核心NOPCommerce的子文件夹中部署php应用程序 - IIS deploy php application in subfolder of ASP.NET core NOPCommerce 无法将 ASP.NET Core 2.1 Angular 应用程序部署到 Azure - Unable to Deploy ASP.NET Core 2.1 Angular Application To Azure 是否可以将ASP.NET应用程序部署为桌面应用程序(带有服务器组件) - Is it possible to deploy an ASP.NET application as desktop application (with server component)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM