Work

Docker and Azure Container Registry

Cloud
Docker

A .NET website deployed using Docker and Azure Container Registry.

Soft pink and baby blue water ripples together in a subtle texture.

This website application was my project on my Assestment on Cloud Engineer to showcase my skills on Docker and Azure Container.

Key Technologies

  • Front End: .Net
  • Container: Docker and Azure Container.

This project showcases my ability to integrate various technologies to build a complete and functional application using Docker and Azure Container.

Docker Installation and Project Setup

  1. Create Azure Container Registry: Go to the Azure Dashboard, search for “Container Registry”, and create a new one. Enter the required information on the “Basic” tab. You can skip Networking, Encryption, and Tags, leaving them at their default values, then click “Review and Create”.
  2. Install Docker: Go to the Docker website and download Docker Desktop.

Dockerfile Creation with .NET

  1. Create a project directory and run the following command in your terminal:
    dotnet new mvc -n HelloWebApp
  2. Run the .NET project to test it:
    dotnet run
  3. Copy the localhost link provided and paste it into your browser.
  4. Create a file named Dockerfile in the root of your project directory with the following content:
# Use .NET 7.0 runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["HelloWebApp/HelloWebApp.csproj", "HelloWebApp/"]
RUN dotnet restore "HelloWebApp/HelloWebApp.csproj"
COPY . .
WORKDIR "/src/HelloWebApp"
RUN dotnet build "HelloWebApp.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "HelloWebApp.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HelloWebApp.dll"]

Image Build and Verification

  1. Build the Docker image:
    docker build -t hellowebapp .
  2. Run the container to verify it works:
    docker run -p 8080:80 hellowebapp

Push to Azure Container Registry

  1. Log in to your Azure Container Registry. You can find the credentials under “Access keys” in the Azure portal.
    docker login ronaldbarueloregistry.azurecr.io --username ronaldbarueloregistry --password <your-password>
  2. Tag the Docker image for your registry:
    docker tag hellowebapp ronaldbarueloregistry.azurecr.io/ronaldbaruelo/hellowebapp:latest
  3. Push the image to the Azure Container Registry:
    docker push ronaldbarueloregistry.azurecr.io/ronaldbaruelo/hellowebapp:latest