Simple Instructions for Running Docker Containers on Azure

Ms. BMs. B
3 min read

Requirements for this project:

  1. Active azure subscription

  2. Visual Studio Code (The following should be installed on the VScode through Extensions: Azure cli, Docker and Git (if you want))

  3. Docker desktop (optional)

In this project, I would be doing the following things to achieve my desired result.

a. Containerize an application

b. Create an Azure Registry and Container Instance

c. Build a Docker image and push it to Azure

d. Deploy the image to Azure Container Service

Let’s get started by creating a folder on VS Code. In the folder, create a file named index.html where you would save the codes for your app. After that has been done, create another file named dockerfile, here you would save your command to build your docker image.

  1. Log in your Azure account and create a Container Registry.

  1. Create a Resource Group if you don’t have one already and give your registry a name.

    I left every other field in default mode and went straight ahead to Create.

  1. My Container Registry has been successfully deployed. Take note of the Login Server information as you would be needing it to build your docker image.

  1. Go to Settings, click Access Keys and Activate the Admin User.

    You need to activate the Admin user to be able to create an Azure Container Instances. After you have done this, it is time to go build the docker image.

  1. Go to VS code, open a Terminal and type az login . az login helps you login to your azure account.

  1. After successfully logging into your Azure account, you type az acr login —name <the name of your azure container registry>. When that has been successful, you go ahead and build your docker image by running, docker build . -t <login server info>/<name of the image you want to create:latest>

  1. At this point, you can open your docker desktop to confirm that the image has been created. Though this stage is optional, I chose to confirm what I had done.

  1. We need to push the image we have created to Azure so that we can use it. For that purpose, I ran the docker push command. docker push <login server info>/<image name>

  1. Coming back to Azure to confirm that my image has been successfully pushed, I opened my Container Registry, clicked on Services, then Repositories and voila, my image has been pushed to my Azure Container Registry.

  1. Create a Container Instance.

  1. Choose your Resource Group, give the container instance a name.

  1. For image source, choose the container registry you had earlier created. Choose your Registry and choose your Image from the drop-down menu.

    Click Create.

  1. Deployment successful. You can go ahead and copy the Public IP address.

  1. open a new tab, paste and run the public ip adddress.

Challenges I faced while working on this project:

  1. When I typed my commands for the dockerfile, for the FROM command, I mistakenly typed Nginx instead of nginx. I kept wondering why I was having an error indicator on the dockerfile. The error only left when I changed the N to n.

I hope you enjoyed stopping by my blog post. Thank you and see you on my next post.

2
Subscribe to my newsletter

Read articles from Ms. B directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ms. B
Ms. B

Hi, I'm a tech enthusiast who has decided to document her cloud journey as the day goes by. Stay tuned and follow me through this journey which I believe would be a wonderful experience. I'm also a team player who loves collaborating with others to create innovative solutions.