Open In App

Docker – Setting ASP.NET

Improve
Improve
Like Article
Like
Save
Share
Report

Pre-requisites: Docker

Microsoft’s leading web development framework for constructing server-side applications is ASP.Net. Docker has assured that it supports ASP.Net because it has been around for a long time for development.

The following steps must be completed before executing ASP.Net

Step 1: Because this is only compatible with Windows computers, you must first guarantee that you have either Windows 10 or Windows Server 2016.

Step 2: Next, make sure Hyper-V and Containers are installed on your Windows system. Go to Turn Windows Features ON or OFF to install Hyper-V and Containers. Then, check the Hyper-V and Containers options and press the OK button.

Check Hyper-V& Containers installed

 

After this procedure, the system may need to be restarted.

Step 3: Then, use the Powershell command below to install the Docker 1.13.0rc4 version. The following command will download it and save it to a temporary place.

Invoke-WebRequest "https://test.
docker.com/builds/Windows/x86_64/docker-1.13.0-
rc4.zip" -OutFile "$env:TEMP\docker-1.13.
0-rc4.zip" –UseBasicParsing 
HTTPS REQUEST

 

Step 4: The archive must then be expanded using the PowerShell command below.

Expand-Archive -Path "$env:TEMP\
docker-1.13.0-rc4.zip" 
-DestinationPath $env:ProgramFiles
Extract files

 

Step 5: Next, use the following PowerShell command to add the Docker Files to the environment variable.

$env:path += ";$env:ProgramFiles\Docker" 

Step 6: Use the PowerShell command to register the Docker Daemon Service.

dockerd --register-service 

Step 7: Finally, use the following command to start the docker daemon.

Start-Service Docker

To ensure that the docker daemon is operational, use the docker version command in PowerShell.

Status of Docker daemon

 

Steps to Installing the ASP.Net Container

Let’s look at how to set up the ASP.Net container.

Step 1: The first step is to get the Docker Hub image. When you connect to Docker Hub, you will be able to search and view the Microsoft/aspnet image, as shown below. Simply enter asp into the search box and click on the Microsoft/aspnet link that appears in the search results.

Dockerhub images

 

Step 2: The Docker pull command for ASP.Net will be shown in the repository metadata on Docker Hub.

Docker hub

 

Step 3: Run the Docker pull command for the Microsoft/aspnet image on Docker Host. It’s worth noting that the image is quite large, around 4.2 GB.

Pulling image

 

Step 4: Now, navigate to https://github.com/Microsoft/aspnet-docker and download the full Git repository.

Step 5: Make an App folder in your C drive. Then, on your C drive, copy the contents of the 4.6.2/sample folder. Go to the Docker File in the sample directory and run the command.

docker build –t aspnet-site-new –build-arg site_root=/ 

The following points should be observed regarding the preceding command:

  • The Docker File is used to create a new image called aspnet-site-new.
  • The local path folder is specified as the root path.

 

Step 6: It’s now time to start the container. 

docker run –d –p 8000:80 –name my-running-site-new aspnet-site-new 
Creating docker container

 

Step 7: IIS will now be operating within the Docker container. To determine the IP address of a Docker container, use the Docker inspect command, as illustrated below.

inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" my-running-site-new
Inspecting docker IP addresses

 



Last Updated : 17 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads