Ref: https://stormpath.com/blog/tutorial-deploy-asp-net-core-on-linux-with-docker
1. Creating an ASP.NET Core project
mkdir AspNetCoreHelloWorld
cd AspNetCoreHelloWorld
dotnet new web
--- Check
dotnet restore
dotnet run
The project should start listening on http://localhost:5000. Try it out in your browser!
2. Building a Dockerfile for ASP.NET Core
--- Dockerfile
FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /app
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000
ENTRYPOINT ["dotnet", "run"]
----
Save into folder of aspnetcorehelloworld
3. Creating the Docker image @ folder of aspnetcorehelloworld
docker build -t mydemos:aspnetcorehelloworld .
4. Test
docker run -d -p 8080:5000 -t mydemos:aspnetcorehelloworld
沒有留言:
張貼留言