Deploy an application for Azure Container Registry (Overview Docker container and image)

Rebai Hamida
3 min readDec 2, 2021

Introduction to Docker Images

Docker is a tool that makes it easier to create, deploy, and run applications by using a containerization approach. These containers are lightweight and take less time to start than traditional servers. These containers also increase performance and lower cost, while offering proper resource management. Another benefit to using Docker is that you no longer need to pre-allocate RAM to each container.

Docker container and Docker image

A Docker container is a virtualized runtime environment used in application development. As metionned before in the definition of Docker, with Docker, we are able to create, run and deploy applications that are isolated from the underlying hardware. A Docker container can use just one machine, share its kernel and virtualize the OS to run more isolated processes. So, Docker containers are lightweight.

A Docker image is like a snapshot in other types of VM environments. It is a record of a Docker container at a specific point in time. Docker images are also immutable. While they can’t be changed, they can be duplicated, shared or deleted. The feature is useful for testing new software or configurations because whatever happens, the image remains unchanged.

Containers require existing runnable image to exist. They are dependent on images, because they are used to construct runtime environments and are needed to run an application.

Containers deployment

If we come back to our 5R Strategy for Cloud Migration dedicated to containers, we can see how we can deploy if we want to rehost, or refactor, use the microservice approach if we decide to rearchitect and for new application we have to build patterns to adopt cloud native strategy in the future.

Containers deployment

Prepare the environment for running containers locally

Let’s prepare our environment for running containers locally

We need to install Docker Desktop it is free

This week, 8 November, Microsoft made generally available to users worldwide its latest versions of Visual Studio and .NET.

Users can download Visual Studio 2022 and .NET 6.

We will use in this session the latest version of Visual Studio.

We need an azure account to be able to create an azure container registry.

Create a Docker Image

To create a docker image we use two methods:

Interactive method

With this method, users will run a container from an existing Docker image and manually make any specific changes to the environment before saving the image. The method is the easiest and the simplest method to create docker images.

How? Follow these steps:

1- Launch Docker and open a terminal session.

2- use the Docker run command image_name:tag_name. This starts a shell session with the container that was launched from the image.

3- If the tag name is omitted, Docker uses the most recent version of the image.

4- The image should appear listed in results.

Dockerfile method

This approach requires making a plain text Dockerfile. The Dockerfile inludes all the specifications to create an image. This process is more difficult and time-consuming, but it does well in continuous delivery environments. The method includes creating the Dockerfile and adding the commands needed for the image. Once the Dockerfile is started, the user sets up a .dockerignore file to exclude any files not needed for the final build. The .dockerignore file is in the root directory. Next, the Docker build command is used to create a Docker image and an image name and tag are set. Lastly, the Docker images command is used to see the created image.

Next: Deploy an application for Azure Container Registry (Part 2: Build and store images by using Azure Container Registry ) | by Rebai Hamida | Dec, 2021 | Medium

--

--

Rebai Hamida

Senior Cloud Application Architect, Microsoft MVP in Developer Technologies, MCT, Technical writer, Speaker