Sunday, October 4, 2020

Docker in Azure

What is Azure Container Instances

Azure Container Instances (ACI) allows us to deploy individual containers in Azure without having to provision Virtual Machines.

It is kind of a serverless computing environment where we can deploy our applications as Docker containers in Azure Container Instances. 

Creating an Azure Container Registry (ACR)

 We can create an Azure Container Registry (ACR) in different ways, using Azure CLI or Azure Portal or Powershell. In this post, we shall see how to create an Azure Container Registry using Azure CLI. 

The first step in creating an Azure Container Registry (ACR) using Azure CLI is to log in to Azure CLI. Open a command prompt and enter the command.

What is Azure Container Registry?

 Azure Container Registry is like a private DockerHub in Azure. It is a managed private Docker registry service based on the open-source Docker Registry 2.0. Create and maintain Azure container registries to store and manage your private Docker container images and related artifacts.

We can configure to push the docker images into Azure Container Registry. Familiar tools such as Azure DevOps and Jenkins CI/CD pipeline can be configured to use Azure Container Registry as a build endpoint. 

Azure CLI

 Azure CLI (Command-line Interface) is a command-line tool for Manager azure services. It's like Angular CLI, it provides various commands to manage Azure services in an Account. Before we can start using Azure CLI we need to install it, the latest version of Azure CLI can be installed from the following site.

https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest

Once Azure CLI is installed run the az --version command to make sure that the installation was done successfully. 

Thursday, October 1, 2020

Docker in Visual Studio

Create Docker Image with .Net Core executable

 In the previous post we saw how to create an Executable (.exe file)  for a .Net Core console application. In this post we shall see how to package this .exe into a Docker image and deploy it as a Docker Container. 

First we will have to create a Dockerfile, we will create this file in the publish folder where the publish results (.exe files) are created.    

Creating Executable from .Net Core Application

.Net Core applications by default will create .dll executables, in this post we shall see how to explicitly create a .exe using .Net Core, in the next post we will see how to use this .Exe and create a Docker image. 
Let’s start by creating a .Net Core Console App using Visual Studio.

Monday, September 28, 2020

Updating Dockerfile and rebuilding images using VisualStudio

 In the previous post we saw on how to create a .Net Core console App and use Visual Studio to automatically add Dockerfile to the project. In this post, we will see how to change the Dockerfile created by Visual Studio and rebuild the Docker image with the modified file.

Once the Dockerfile is created we can manually exit the Docker file Add/Modify steps and rebuild the Docker image.

In this sample, we will add proxy settings to enable package restore in a Corporate firewall environment.

Create Dockerfile and Container using Visual Studio

 Visual Studio provides an option to automatically add Docker support. Using Visual Studio we can add the Dockerfile to a project without having to manually create one. Visual Studio will create the Dockerfile with the commands pre-populated based on the type of project, we create. 

In this post, we will create a Console application using .Net Core and use Visual Studio to automatically create the Dockerfile for the Project. First, let us create the following Console application.

Docker Getting Started

Friday, September 25, 2020

Building an ASP.Net Core Web App Docker image

 In this post we shall see how to create a basic Asp.Net core Hello World App and package it into a Docker image. We will deploy the image as a Docker container and execute the Asp.Net Core application from Docker.

First let us start by creating an Asp.Net Core application using Visual Studio 2019

Building a Node App Docker image

 In the previous post we saw how to build a HelloWorld Docker image, in this post we will create a Docker image for a Node.js application.

First let us create a basic Node server using Express which will respond with a Greeting message in the root path (/).

Building a HelloWorld Docker images

 We have seen how to pull a Docker image from DockerHub and run in, now we will see how to create our own Docker image, build and run it.

The first step to create a Docker image is to create a Dockerfile.
Dockerfiles is a text file that contains instructions and steps to create a new Docker image.

A Dockerfile has no extension. If you are using docker on windows use notepad to create a dockerfile while saving select "All type" and save the file name as "Dockerfile".

Friday, September 18, 2020

Listing and Removing Docker Images

In the previous post we saw on how to pull and run Docker Images from a remote repository. Once we pull a Docker Image, it gets stored in the local repository. We can use the image ls command to view the list of images in the local repository.

Listing and Removing Docker Containers

Docker supports a set of commands to operate on Docker Containers. It supports commands to list Containers, Remove containers etc. Below are some of the commonly used commands for Docker Containers.

Pulling Docker Images

In the previous post we executed the docker run command and noticed that the Docker Engine automatically pulled the hello-world image from DockerHub. We can also use the docker pull command to explicitly pull Docker images from the remote repository (DockerHub) to our local DockerRepository.

To pull images from the remote repository to the local repository we need to use the docker pull command as follows.

Running first Docker Container

Once we install Docker and make sure it is up and running we can start running our first Docker Container. Let us run the hello-world Docker container, this container is present in the DockerHub. We will use the docker run command to run the container as follows.

Monday, September 14, 2020

Docker Desktop

 Depending on the version of Windows operating system, we need to either install the Docker Toolkit or Docker Desktop. For Windows version less than 10, we cannot install Docker Desktop for these versions we need to install Docker Toolkit. For Windows 10 we can install Docker Desktop. It is recommended to install Docker Desktop.

Once Docker Desktop is installed, it will start and we can see an icon in the Toolbar.

Installing Docker

 To get started with using Docker we need to download and install the Docker setup. Docker can be installed in multiple platforms Windows / Mac / Linux. We can get the appropriate version of Docker from the below link and install it to get started.

https://docs.docker.com/get-docker/