You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avinash Thakur edited this page Feb 10, 2019
·
3 revisions
Create a Dockerfile for an ASP.NET Core application
Step 1 : Create a Dockerfile in your project folder.
Step 2 : Add the text below to your Dockerfile
FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "aspnetapp.dll"]
Step 3 : To make your build context as small as possible add a .dockerignore file to your project folder and copy the following into it.
bin\
obj\
Step 4 : Build and run the Docker image. Open a command prompt and navigate to your project folder.Use the following commands to build and run your Docker image: