Description: Here I have explained, how to deploy sample Dotnet core application into docker container
Prerequisites:
- Dotnet core sample application
- Ubuntu machine with Docker engine
Procedure:
First I am going to publish sample Dotnet core application using command prompt from the development machine. Open the source code/ project path in cmd like follow:
Publish the code using dotnet publish command, It will create publish folder in project path WebApplication1\bin\Debug\netcoreapp2.1\publish
Copy publish folder to the docker server using winscp. After copying publish folder, create the Docker file to create Dotnetcore image and copy it to source code.
This docker will create image from dotnetcore sdk and publish on port 80 by using WebApplication1.dll
FROM mcr.microsoft.com/dotnet/core/sdk:2.1 ### sdk url path is depend on your dotnet core version WORKDIR /app COPY . . ENV ASPNETCORE_URLS http://*:80 EXPOSE 80 ENTRYPOINT ["dotnet", "WebApplication1.dll"] ### .dll file for your project in this example it is WebApplication.dll
Upload Dockerfile to publish folder as follow:
After copying files take ssh console of docker instance and navigate to publish folder
Build the docker image using source code using docker build command to create image with the name of techservercoreapp from publish folder
# cd /home/serverapprunner/publish
# docker build -t techservercoreapp .
Once the image being prepared, you will get in list of docker image as follow:
Run the docker container on port 80 using the techservercoreapp image using below command
# docker run -td -p 80:80 techservercoreapp
Browse the docker engine IP in browser
No comments:
Post a Comment