In this tutorial, we are going to see how to deploy a Docker image created with ASP.Net Core 1.0 Application to an Ubuntu Virtual Machine created in Microsoft Azure Cloud. Docker helps us in creating packages for our application into standard images. These Docker images are ready to be deployed on Docker Containers and can run on any environment.
The power of Docker comes from its containers which wrap everything needed to run our application, for example code, runtime, dependencies, tools etc. This will ensure that our application will always run irrespective of hosting environment.
As a prerequisite for current tutorial, one has to create a Docker Image of an ASP.Net Core 1.0 Application and push the image to Docker Hub by following Create and Deploy Docker Container of ASP.Net Core 1.0 Application to Azure Linux Web Application.
Now lets get started by creating an Ubuntu Virtual Machine in Azure Cloud. Select Ubuntu Server 16.04 LTS.
Click Create. Fill in the required details like Name. Select Password as the Authentication Type.
For Size, I have selected DS1_V2 Standard 1 Core 3.5GB RAM. I left out all the other default settings and created the virtual machine.
The overview of the Virtual Machine displays the IP Address, we need this IP Address to connect to the VM.
Once VM is created, download and install Putty SSH and Telnet client on your local environment. Run Putty Client and enter the VM IP Address as shown below and click Connect.
We will get an alert to cache the server’s host key. Click No.
Login to the console by providing the username and password (which we provided at the time of VM creation).
Now lets install Docker on VM. First lets become root on VM.
Install Docker using following command.
apt-get install -y docker.io
Start the Docker service and also configure it to start on system boot.
systemctl start docker
systemctl enable docker
Now check Docker version using following command.
Lets pull the Docker Image which we created as part of Create and Deploy Docker Container of ASP.Net Core 1.0 Application to Azure Linux Web Application.
docker pull ramiramilu/dockerdotnetcoreapp
To check if Docker image is downloaded, execute below command.
Run the downloaded Docker image using following command.
docker run -p 8000:5000 ramiramilu/dockerdotnetcoreapp
Finally we need to add an inbound rule to allow traffic on 8000 port. Find the Network Security Group.
Click on the Network Security Group, Select Inbound Security Rules. click Add to add a new Inbound Rule.
Add 8000 port rule as shown below and click ok.
Navigate to the IPAddress:8000, we should see our application up and running.
So we finally made our ASP.Net Core 1.0 application up and running on Azure Ubuntu Virtual Machine using Docker Containers.
That’s it for now. Happy Coding and Stay Tuned!!!