The Wayback Machine - https://web.archive.org/web/20240119132905/https://www.geeksforgeeks.org/microsoft-azure-running-an-app-inside-a-docker-container-image/
Open In App
Related Articles

Microsoft Azure – Running an App inside a Docker Container Image

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

In this article, we’ll learn how to run an app inside of a container with Docker. For this, you need to set up Docker on your local Dev machine, by going to docker.com, and installing the Docker desktop application for your specific operating system. We can use the Docker Pokemon to pull an image from the Docker Hub onto your local machine. 

Here, we’re going to use that same image to create a running container. We will open up our command line terminal and start by typing in the Docker images command. 

docker images

This should list all of the available images that are on our machine, and this should include that microsoft/asp.netcore-build image. 

Now we are going to execute another Docker command to run that image:

docker run -it --name myapp microsoft/aspnetcore-build

And this is going to signal to the Docker client that we actually want to run this image in a container. The  -it is used to specify that we want to engage with the container using an interactive terminal. Then we have given our image a name. We’re going to call this “Myapp”. The last thing we need to do is specify the name of the image we want to use to create this container.

 In no time at all, our container has been started, and we’re now connected to it by an interactive terminal. 

So, since this is a.NET container, we should be able to use the below command:

 dotnet --info

It gets some info about the.NET command-line tools, that SDKs that are available.

We can also type in uname -r, and this should give us some information about the operating system and Kernel. Since we are running on a Linux container. 

Next, let’s actually create a.NET application. So, first thing we’ll do is we’ll create a folder. We’ll call this “Myapp”. 

Next, we’ll type in dotnet new and the type of application we want to create. So, in this case, we want to create a new console application. 

Now, all we need to do is type dotnet run, and as expected it prints out “Hello world!” from the script because that’s really all our simple console application is doing. 

So, you’ve just seen how easily we could create a container based on an image that we have on our local Dev machine, and create a running application inside of it.

Lost in the complex landscape of DevOps? It's time to find your way! Enroll in our DevOps Engineering Planning to Production Live Course and set out on an exhilarating expedition to conquer DevOps methodologies with precision and timeliness.
What We Offer:
  • Comprehensive DevOps Curriculum
  • Expert Guidance for Streamlined Learning
  • Hands-on Experience with Real-world Scenarios
  • Proven Track Record with 100,000+ Successful DevOps Enthusiasts

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 31 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials