Creating-a-container-image-and-uploading-to-azure-through-azure… by Gbolahan AwobajoCreating-a-container-image-and-uploading-to-azure-through-azure… by Gbolahan Awobajo

Creating-a-container-image-and-uploading-to-azure-through-azure…

Portfolio project
Gbolahan Awobajo

Creating-a-container-image-and-uploading-to-azure-through-azure-container-registry

This documentation explains how to create a container image and upload it to Azure's Container Registry (ACR), covering setup, image creation, and the upload process.

Introduction

This guide walks through the essentials of deploying a Docker container image to Azure Container Registry. Whether you're new to containerization or experienced with Docker, this step-by-step approach will clarify the deployment workflow.

Steps

Provision a new virtual machine (VM) on Azure.
Install Docker on the VM.
Set up an Azure Container Registry (ACR) in the Azure portal.
Transfer application code to the VM using FileZilla.
Build the Docker image.
Tag and push the image to ACR.
Verify the image in ACR.

Step 1: Provision a New Virtual Machine (VM)

Go to the Azure portal and navigate to Virtual Machines.
Select Create and configure the VM with your preferred OS (e.g., Ubuntu or Windows Server) we will be using a linux vm
Complete the setup, and then connect to your VM using SSH or RDP.

Step 2: Install Docker on the VM

Follow these steps to securely install Docker on your Ubuntu VM:
Update the package list:
sudo apt-get update
Install necessary certificates and curl:
sudo apt-get install -y ca-certificates curl
Create a directory for storing Docker's GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
Download Docker's official GPG key:
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc
Add Docker's repository to the apt sources list:
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Update package information again and install Docker:
sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Verify Docker installation:
docker --version

Step 3: Set Up Azure Container Registry (ACR)

In the Azure portal, navigate to Container Registries and select Create.
Configure the registry by selecting a Resource Group, Registry Name, and Region.
Choose an appropriate SKU and complete the setup.

Step 4: Transfer PHP Code from VSC to the VM Using FileZilla

Since i already prepared the PHP files in Visual Studio Code. ow i can transfer them to my VM, but firstly make sure you have the dockerfile in your vsc before transferring
Open FileZilla and connect to your VM by entering the IP address, username, and password (or SSH key) in the connection settings.
Locate the PHP project directory on your local machine (from VSC) and the corresponding destination directory on the VM.
Transfer the files to the VM, e.g., /home/Cloudtest/phpapp.

Step 5: Build the Docker Image for the PHP Application

In this step, you will customize the Docker image for your application. You will use a PHP 8.2 with Apache base image, but this step can easily be adapted for other environments like Java, Python, or Node.js.
After transferring the PHP files, you are now ready to build the Docker image:
SSH into your VM and navigate to the directory where the PHP code was transferred (e.g., /home/Cloudtest/phpapp).
Build the Docker image:
docker build -t phpapp .
Let's see if the container is working as expected, run the container with the following command, which will expose the application on port 80:
docker run -d -p 80:80 phpapp
After running the container, open a browser and navigate to your VM's public IP address. You should be able to see your application running.

Step 6: Tag and Push the Image to ACR

Go to the azure portal and go to the registry created and go to the access key and select the "Admin user" option to see your Password. You will need to note the registry name, login server and username details
login to the server on from your ssh terminal and run : sudo docker login (login server) -u (username) -p (password)
Tag the image with your ACR registry's login server: sudo docker tag (docke rname) (name of server)/(image name)
Push the image to ACR: sudo docker push
chcek the ACR dashborad to see your container

Conclusion

By following the steps outlined in this guide, you have successfully:
Provisioned a new Azure VM.
Installed Docker and configured it for use.
Built a custom Docker image for your application.
Uploaded the image to Azure Container Registry (ACR).
Run the container and tested it by exposing it on port 80.
Your application is now containerized and ready for deployment in the cloud, ensuring a scalable and reliable infrastructure. You can further expand this setup by deploying your container to Azure Container Instances, Azure Kubernetes Service, or other Azure services for production use.

Additional Resources

For further information and in-depth details, refer to the official Docker and Azure documentation:
Thank you for following this guide! Feel free to explore more and customize your containerized application as per your needs.

0 likes · 0 views · Nov 29, 2026

Documents how to provision an Azure VM, build and run a Docker image for a PHP app, and push it to Azure Container Registry.

Tags