dockerfile 

FROM microsoft/aspnetcore:2.0
COPY . /docker1
WORKDIR /docker1
EXPOSE 7000
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.0\publish> docker build -t docker1 .

运行image

 docker run -it -p 7001:7000 docker1

 

posted on 2018-07-16 17:42  chester·chen  阅读(149)  评论(0编辑  收藏  举报