This article shares basics of Docker and deployment details of Docker with asp.net Core. You will find how experts of .Net Development Company use Docker for asp.net core deployment in this article. Read it thoroughly and find what professionals want you to know about Docker software and its deployment.
WHAT IS DOCKER ?
Docker refers to a software that helps in creating an image that looks like a virtual machine template and then execute that image instance in a container.
Docker Hub refers to the large repository of images maintained by the Docker. It cab be used as starting points for images. Simply install the Docker, select an image and then run its instance in container.
Asp.Net Core Deployment with Docker Hub
Consider an Asp.net project (an open source project) which monitors the Docker server activity. Since it is required to run the Docker dash in a container, the project needs to be delivered on Docker Hub as a Docker image. The main requirement is to automate the process of deployment such that the app is tested, build and released on each commit.
Docker Hub makes it possible to make images automatically from a repository of GitHub as long as a Dockerfile is there in the repo. It is possible to build an Asp.Net app inside the Docker container.
The main issue is that the onbuild image of dotnet is quite large of around 500MB. A different image is available for deployment purpose that contains the .Net core (including the libraries and the runtime) and it can run the portable dotnet applications. It would be needed to compile the code in order to use the runtime image and the output of the compiled code is copied in the image.
In order to compile the Asp.Net app outside the container, it is required to use a build server. AppVeyor build server can be used for this purpose. It can easily test, build and deploy the .Net apps and it has a subscription plan that is free for open source projects. However, it is possible to push only the .Net code with AppVeyor and not the docker image. The available solution is to use AppVeyor to get the build artifacts and then use GitHub on another branch using the git push of AppVeyor.
Following is the pipeline for Asp.Net Core continuous deployment:
1) Commit all changes to the master branch.
2) The master branch will automatically be pulled by the AppVeyor.
3) Build script executed by AppVeyor.
4) Dotnet restore will be invoked by the build script.
5) Dotnet build will be invoked by the build script.
6) Dotnet test will be invoked by the build script.
7) Dotnet publish will be invoked by the build script.
8) All the changes will be committed by the AppVeyor to the local branch.
9) AppVeyor will push the commit to release ranch.
10) Release branch will automatically be pulled by the Docker Hub.
11) Docker Hub will create image with the help of Dockerfile.
12) Finally, the image will be published by the Docker Hub under latest tag.
Using Docker with Windows
Docker can be quickly configured on Windows OS and a nodejs app can be hosted inside the docker container.
Many challenges were faced by users with the build server while triggering two builds at the same time (with nodejs and angularjs app). Also, there was a need of smart options for releasing code frequently to the production. So docker was decided as a solution. But it was quite complicated to run Docker on Windows 7 as compared to Windows 10(hyper-v).
Check if the operating system has Hyper-V.
1. For windows without Hyper-V, enable the virtualization in bios.
2. For windows with Hyper-V, enable the Hyper-V before executing the Docker installer.
Window OS without Hyper-V
Execute the docker toolbox. There will be three icons on the desktop once the toolbox is installed as shown below:
To get started, double click the Docker Quickstart. As a result, boot2docker will be downloaded and all necessary settings will be applied. Save the IP address that will appear on the welcome screen. It will be needed to access the application hosted in the docker container. Docker Quickstart will make a default VM that will be used to run the application. Use the following command in order to map the docker VM with local folder and container with VM.
Docker-machine stop default
In this command, the default VM machine is shut down for the docker. If the docker-machine is not recognized by the command prompt, check if the docker folder has been added the environment variable PATH. In case, it has not been added , go to the head and then add it. While making an update to the variable PATH, consider your system path as well.
In order to start the docker VM, run the following command:
Docker-machine start default
Once the local folder is mapped to the docker VM, to access the folder, connect it to docker VM first, add a folder in VM and then mount the host folder to the VM folder.
In order to change the CPU or RAM of the docker VM, set the same using the Oracle VM Virtual box. Consider the system tab below default VM.
Windows OS With Hyper-V
It is quite simple to install Docker on the Operating system with Hyper-V. After the installation is complete, a docker icon will be displayed in the notification area. In order to change the RAM/CPU, right click on the icon and use settings option from menu as shown in the figure.
Docker makes it more easy and fast to recreate/create an environment that can be shared or shipped. With the help of Docker Hub, many new technologies that are preconfigured can be explored.
As you have learnt that Docker software helps in developing image that appears like virtual machine template. It later executes that image instance in a container. Now you also know how .net development company experts perform asp.net core deployment with Docker Hub. Still if there is any doubt, ask the experts directly in comments.