docker webapi

时间:2023-11-22 20:27:38

dockerfile

FROM microsoft/aspnetcore:2.0
COPY . /docker1
WORKDIR /docker1
EXPOSE
ENTRYPOINT ["dotnet", "docker1.dll"]

Program.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; namespace docker1
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
} public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://*:7000")
.UseStartup<Startup>()
.Build();
}
}

创建image

PS G:\NetDemo\docker3\docker1\bin\Release\netcoreapp2.\publish> docker build -t docker1 .

运行image

 docker run -it -p : docker1

docker webapi