Problem description

In Bowen (【Azure App Service For Container】 establish ASP.NET Core Blazor Project and package it as Linux Image released to Azure Application service ) In which we pass VS 2019 You can add Dockerfile And automatically generate Docker Image file . But without the help of VS2019 How do we operate it ?

Solution steps

Get ready Dockerfile

Enter the project folder , establish Dockerfile and COPY The following content :

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
ENV ASPNETCORE_URLS=http://+:8000 

WORKDIR /app
EXPOSE 8000
EXPOSE 5000 COPY . /app/
ENTRYPOINT ["dotnet", "MyLife.Blazor.Server.dll"]
  • FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base   and  FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build Can be in Docker Hub The version image for is found in (https://hub.docker.com/_/microsoft-dotnet-sdk)
  • COPY . /app/ Namely the dockerfile Copy all files in the same directory to the image app Directory

Create a mirror image

adopt CMD Go to the current directory , Use  docker build -t mywebimages .  ( Particular attention : The main points in the order must be ., The highlighted part in yellow is replaced with a custom image name . Detailed Command Reference Docker explain :https://docs.docker.com/engine/reference/commandline/build/

When the command is finished , stay Docker Desktop You can see the current Images

Running the mirror , Verify that the project runs successfully

stay Docker Desktop in Run At present Image Or by docker run Command to start Container: docker run --name testweb -p 8080:8000 mywebimages

  Command start output :

C:\MyCode\MyLife\MyLife.Blazor\MyLife.Blazor\Server\bin\Release\net5.0\publish>docker run --name testapidemo -p 8080:8000 mywebimages
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
Storing keys in a directory 'C:\Users\ContainerUser\AppData\Local\ASP.NET\DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://[::]:8000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\app
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect.

 

visit Docker Container Specified port 8080 The result is :

Reference material :

Docker Hub: https://hub.docker.com/_/microsoft-dotnet-sdk

establish ASP.NET Core Blazor Project and package it as Linux Image released to Azure Application service : https://www.cnblogs.com/lulight/p/14315383.html

windows On the use of VS2019 Developed .NETCore How to package and deploy a project to linux Docker in : https://blog.csdn.net/weixin_48000648/article/details/106524426

【Azure Developer】 It's been released .NET Core How to package project files as Docker More articles on mirror files

  1. take ASP.NET Core 1.0 Application as docker Image Publishing (Linux edition )

    var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...

  2. Spring Boot Integrate servlet, Publish to run directly war package , Convenient for subsequent packaging docker Mirror image .

    background :Spring Boot Integrate servlet, Publish to run directly war package , Convenient for subsequent packaging docker Mirror image . Original address https://github.com/weibaohui/springboot ...

  3. jenkins Automatic packaging generation docker Automatically publish and update after mirroring nginx Agent access

    I wrote before docker And jenkins Based on using   https://www.cnblogs.com/xiaochangwei/category/816943.html Now the function of setting up the environment is : 1.jen ...

  4. ASP.NET Core 2.0 MVC Release deployment --------- ASP.NET Core The specific operation of Publishing

    ASP.NET Core The specific operation of Publishing Use C# Compiling ASP.NET Core Web The project example illustrates the whole process of Publishing . 1. Create project choice “ file ” > “ newly build ” > “ project ”.  stay “ add to ...

  5. Taste alicloud container service : A preliminary attempt to ASP.NET Core Web API Site Docker Automated Deployment

    The deployment scenario is like this , We are based on ASP.NET Core 2.0 Preview 1 Developed a cache management system Web API , Want to use Alibaba cloud container service based on Docker Deploy as intranet service . Share in this blog post ...

  6. Jenkins Integrate Docker The image is automatically published

    1. Ideas & technological process Jenkins Integrate Docker The image realizes automatic publishing and Jenkins Release mavne The idea of the project is the same as that of the overall process by :Jenkins Pull the remote source code -- gitl Implementation of application packaging -- jenk ...

  7. [ translate ] be based on ASP.NET Core 3.0 Of ABP v0.21 The published

    be based on ASP.NET Core 3.0 Of ABP v0.21 The published Just an hour after Microsoft released , be based on ASP.NET Core 3.0 Of ABP v0.21 And then it was released . v0.21 No new features . It's just upgrading to ...

  8. MySQL official .NET Core The driver is out , Support EF Core

    Come out MySQL official .NET Core The driver is out , Support EF Core. yesterday MySQL The official has released .NET Core drive , It's still a preview , But the function is already available . NuGet Address :https:/ ...

  9. Azure Media services release reliable live video platform

    Sudheer Sirivara Azure Director of media services Two months ago ,Azure Media services released a public preview of live video and content protection products . this Internet Large scale live broadcasting solutions have been adopted by more than ten leading international broadcasters ...

  10. NET Core The driver is out , Support EF Core

    NET Core The driver is out , Support EF Core Come out MySQL official .NET Core The driver is out , Support EF Core. yesterday MySQL The official has released .NET Core drive , It's still a preview , But I'm not sure ...

Random recommendation

  1. C# Get the method collection of the current program running path

    // Get the full path of the current process , Include file name ( Process name ).string str = this.GetType().Assembly.Location;result: X:\xxx\xxx\xxx.exe (. ...

  2. linux Shut it down teamviewer service

    One . Situation introduction OS: ubuntu14.04 64bit teamviewer edition :10.0.36281 I saw it turned off just now teamviewer, But by ps Look at the following process , But there is still the process , therefore : Two ...

  3. rewrite Rule writing and nginx To configure location summary

    rewrite Only on the server{},location{},if{} in , And it only works on the string after the domain name except the passed parameters . for example http://seanlook.com/a/we/index.php ...

  4. JavaScript Basic knowledge ——Location Object details

    attribute describe location.hash Set or get URL The anchor in location.host Set or get URL Middle host ( Including port number ) location.hostname Set or get URL The Lord in ...

  5. Mobile web version Meta label

    viewport Most mobile browsers accept , such as Opera Mobile, iPhone, Android, Iris, IE, BlackBerry, Obigo, Firefox The most basic example , stay ...

  6. Learning notes :Zookeeper The election mechanism

    1.Zookeeper The election mechanism Zookeeper Although not specified in the configuration file master and slave however ,zookeeper Working hours , There is a node for leader, Others are follower Leader ...

  7. json Introduction and JsonCpp usage

    [ Time :2017-04] [ state :Open] [ key word : Data exchange format ,json,jsoncpp,c++,json analysis ,OpenSource] json brief introduction This article is just to add my personal opinion on json The understanding of the format , more ...

  8. POJ 3666 Making the Grade( A two-dimensional DP)

    Topic link :http://poj.org/problem?id=3666 The main idea of the topic : Given length is n The whole number sequence of , You can add one number at a time 1 Or minus 1, At least how many times can it become monotonous or monotonous ( subject BUG, We can only ask for it ...

  9. ucos Design of serial communication module

    In embedded applications , Use RTOS The main reason is to improve the reliability of the system , The second is to improve development efficiency . Shorten development cycle .uCOS-II It's a preemptive real-time multitasking kernel , The object of use is embedded system , Cut down the source code properly , It's easy to migrate to 8~32 position ...

  10. use html+css To be a robot cat Source code

    Let's take a look at the rendering , And then look at the source code Is it still very similar Let's look at the source code <!DOCTYPE html> <html lang="en"> <he ...