Authentication protocols NTLM, Kerberos :👈 👉:Terraform

Containerization Overview

Containerization

Containerization is a method of packaging software so it can run reliably across different computing environments. It wraps an application along with its dependencies, libraries, and configuration files into a single unit called a container. These containers are lightweight, portable, and isolated from the host system, making them ideal for consistent deployment across development, testing, and production.

Why use containerization?

  • Portability: Run anywhere—local machine, cloud, or server.
  • Isolation: Each container runs independently.
  • Scalability: Easily replicate containers to handle load.
  • Consistency: No more “works on my machine” issues.

What is Docker

Docker is a popular platform for developing, shipping, and running applications inside containers. It provides tools to create, manage, and orchestrate containers efficiently.

Example: Containerizing a Simple C# "Hello World" Console App

1. Create the C# App

bash dotnet new console -o HelloWorldApp -n HelloWorld 

This creates a folder HelloWorldApp with a Program.cs file that prints "Hello World".

2. Edit Program.cs (optional)


    using System;

    namespace HelloWorld
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello from a Docker container!");
            }
        }
    }

3. Create a Dockerfile

Inside the HelloWorldApp folder, create a file named Dockerfile:


    # Use official .NET SDK image to build the app
    FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

    WORKDIR /app

    COPY . .

    RUN dotnet publish -c Release -o out

    # Use runtime image to run the app
    FROM mcr.microsoft.com/dotnet/runtime:8.0

    WORKDIR /app

    COPY --from=build /app/out .

    ENTRYPOINT ["dotnet", "HelloWorld.dll"]

4. Build the Docker Image

bash docker build -t helloworld-csharp . 

5. Run the Container

bash docker run helloworld-csharp 

You should see:

Hello from a Docker container!

Docker commands

๐Ÿณ Docker Basics

Command Usage
docker --version Check Docker version installed
docker info Display system-wide Docker information
docker help Show help for Docker CLI

๐Ÿ“ฆ Image Management

Command Usage
docker build -t . Build image from Dockerfile in current directory
docker images List all local Docker images
docker rmi Remove a Docker image
docker pull Download image from Docker Hub
docker push Upload image to Docker Hub
docker image prune Remove unused images

๐Ÿš€ Container Lifecycle

Command Usage
docker run Run a container from an image
docker run -it Run container interactively (e.g., with shell access)
docker run -d Run container in detached mode (background)
docker run --name Assign a name to the container
docker start Start a stopped container
docker stop Stop a running container
docker restart Restart a container
docker rm Remove a stopped container
docker ps List running containers
docker ps -a List all containers (including stopped)

๐Ÿ” Container Interaction

Command Usage
docker exec -it sh Open shell inside running container
docker logs View container logs
docker inspect View detailed container info
docker attach Attach to a running container's output
docker cp : Copy files from container to host

๐ŸŒ Networking

Command Usage
docker network ls List Docker networks
docker network create Create a new network
docker network connect Connect container to network

๐Ÿ“ Volumes

Command Usage
docker volume ls List volumes
docker volume create Create a volume
docker volume rm Remove a volume
docker volume inspect View volume details

๐Ÿงน Cleanup

Command Usage
docker system prune Remove unused containers, networks, images, and volumes
docker container prune Remove all stopped containers
docker volume prune Remove all unused volumes

๐Ÿ› ๏ธ Docker Compose (if used)

Command Usage
docker-compose up Start services defined in docker-compose.yml
docker-compose down Stop and remove containers, networks, volumes
docker-compose build Build images defined in compose file
docker-compose logs View logs for all services
Back to Index
Authentication protocols NTLM, Kerberos :👈 👉:Terraform