Wednesday, 10 June 2026

Kubernetes CrashLoopBackOff Fix – Complete Troubleshooting Guide

 

A Kubernetes pod entering the CrashLoopBackOff state indicates that the container is repeatedly starting and crashing.

This is one of the most common issues faced by Kubernetes administrators.

What is CrashLoopBackOff?

You may see:

kubectl get pods

Output:

my-app-6d4fd7c7d8-k9v8t   0/1   CrashLoopBackOff

This means Kubernetes attempted to start the container, but it crashed multiple times.

Step 1: Describe the Pod

Run:

kubectl describe pod <pod-name>

Example:

kubectl describe pod my-app-6d4fd7c7d8-k9v8t

Look for events at the bottom.

Common clues include:

  • OOMKilled

  • Failed Mount

  • Back-off restarting failed container

Step 2: View Container Logs

Check logs:

kubectl logs <pod-name>

If the pod restarted:

kubectl logs <pod-name> --previous

This often reveals the root cause.

Step 3: Check Resource Limits

Verify memory and CPU limits:

kubectl describe pod <pod-name>

Look for:

resources:
  limits:
    memory: 256Mi

If the application requires more memory, increase the limit.

Example:

resources:
  requests:
    memory: "512Mi"
  limits:
    memory: "1Gi"

Step 4: Check Environment Variables

Missing environment variables frequently cause application startup failures.

Review deployment configuration:

kubectl get deployment my-app -o yaml

Verify:

env:
  - name: DB_HOST
    value: database

Step 5: Verify Secrets and ConfigMaps

Ensure required resources exist:

kubectl get secrets
kubectl get configmaps

Missing secrets can cause immediate container crashes.

Step 6: Check Health Probes

Incorrect readiness or liveness probes often trigger restarts.

Example:

livenessProbe:
  httpGet:
    path: /health
    port: 8080

Verify the endpoint actually exists.

Step 7: Check Image Issues

Confirm the image starts correctly:

docker run my-image

Common problems:

  • Missing startup script

  • Wrong entrypoint

  • Incorrect command arguments

Step 8: Check Node Resources

Verify node health:

kubectl top nodes

and

kubectl top pods

Resource exhaustion can cause repeated failures.

Common CrashLoopBackOff Causes

CauseDescription
Application ErrorApplication crashes immediately
OOMKilledOut of memory
Missing SecretConfiguration unavailable
Bad Environment VariablesStartup failure
Failed Database ConnectionApplication exits
Wrong ImageContainer cannot start
Health Check FailureKubernetes kills pod

Useful Commands

kubectl get pods
kubectl describe pod <pod-name>
kubectl logs <pod-name>
kubectl logs <pod-name> --previous
kubectl get events --sort-by=.metadata.creationTimestamp
kubectl top pods
kubectl top nodes


AI Solution : 

AI-Assisted Troubleshooting

When troubleshooting a CrashLoopBackOff issue, engineers often spend significant time collecting logs, reviewing Kubernetes events, checking resource limits, and correlating information across multiple tools.

AI-powered incident analysis can help reduce this effort by automatically analyzing logs, identifying probable root causes, and suggesting remediation steps.

How ResolvAI Can Help

ResolvAI is an AI-powered incident copilot designed to help engineering teams investigate production issues faster. By connecting with your incident management and ticketing systems, it can analyze error logs, correlate related incidents, and recommend potential solutions.

Instead of manually reviewing hundreds of log lines, engineers can quickly understand:

  • Why a pod is crashing

  • Similar incidents that occurred previously

  • Recommended remediation steps

  • Related Jira tickets and historical fixes

Learn more about ResolvAI here:

ResolvAI

If you're exploring AI-assisted incident management for Kubernetes and DevOps environments, ResolvAI can help accelerate root cause analysis and reduce mean time to resolution (MTTR).


Conclusion

CrashLoopBackOff is a symptom rather than the actual problem. The key is to inspect logs, events, resource limits, and application configuration to identify the root cause.

In most cases, logs combined with kubectl describe provide enough information to resolve the issue quickly.

SSH Permission Denied (publickey) Fix in Linux

 

One of the most common SSH errors Linux administrators encounter is:
Permission denied (publickey)

This error occurs when SSH authentication using public keys fails. In this guide, we'll look at the common causes and how to fix them.

Error Message

ssh user@server
Permission denied (publickey)

Common Causes

  • SSH key not present on remote server

  • Incorrect file permissions

  • Wrong private key being used

  • Public key missing from authorized_keys

  • SSH server configuration issues

Step 1: Verify Your SSH Key Exists

Check your local SSH keys:

ls -la ~/.ssh

You should see files such as:

id_rsa
id_rsa.pub

or

id_ed25519
id_ed25519.pub

Step 2: Copy Public Key to Remote Server

Use:

ssh-copy-id user@server

If ssh-copy-id is unavailable:

cat ~/.ssh/id_rsa.pub

Copy the output and append it to:

~/.ssh/authorized_keys

on the remote server.

Step 3: Check Permissions

Incorrect permissions often cause SSH authentication failures.

Run:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Verify ownership:

chown -R user:user ~/.ssh

Step 4: Specify the Correct Private Key

If you have multiple keys:

ssh -i ~/.ssh/id_rsa user@server

You can also add this configuration:

Host myserver
    HostName server-ip
    User user
    IdentityFile ~/.ssh/id_rsa

inside:

~/.ssh/config

Step 5: Enable Debug Mode

Run SSH with verbose logging:

ssh -vvv user@server

Look for messages such as:

Offering public key
Authentication failed

These logs help identify the exact issue.

Step 6: Verify SSH Server Configuration

Check:

sudo vi /etc/ssh/sshd_config

Ensure:

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

Restart SSH:

sudo systemctl restart sshd

or

sudo systemctl restart ssh

Conclusion

The "Permission denied (publickey)" error is usually caused by missing keys, incorrect permissions, or SSH configuration issues. By checking keys, permissions, and server settings, you can quickly restore access.

Have you encountered a different SSH authentication issue? Let us know in the comments.

I Built an AI Tool That Tells You How Safe Your City Is Right Now — Here's How It Works

Written by: Kalyug Rishi Category: AI Tools · Technology · Travel Safety Tags: city safety score, AI safety tool, geopolitical risk, war risk analyzer, travel safety 2026, is my city safe, AI tool India


Reading time: 7 minutes


The world feels more unstable than ever.

Wars are spreading. Geopolitical tensions are rising. And millions of people — travelers, expats, NRIs, students studying abroad, professionals relocating — are asking the same question every day:

"Is it safe where I'm going? Is it safe where I am?"

The answers they find are frustrating. Government travel advisories are updated every few months. News articles are sensational. Travel forums are full of opinions, not data.

So I built something better.

City Safety Score — an AI-powered geopolitical risk analyzer that gives you an instant safety score for any city in the world, based on current war risk, conflict proximity, and regional stability.

In this post I'm going to show you exactly what it does, how it works, and why AI is the future of travel safety intelligence.


What Is City Safety Score?

City Safety Score is a free AI tool that analyzes the geopolitical and war risk situation for any city and country you enter — and returns a detailed safety assessment in under 5 seconds.

You type in a city. You type in a country. You hit analyze.

The AI returns:

  • An overall safety score from 0 to 100 — where 100 is completely safe and 0 is critical danger
  • A travel advisory level — Safe to travel / Exercise caution / Avoid non-essential travel / Do not travel
  • 6 detailed risk factor scores — each rated from 0 to 100
  • Active risk flags — specific current threats in plain language
  • A written AI advisory — a 2-3 sentence expert-level summary of the situation

All of this in under 5 seconds. For any city. In any country. Free.

Try it here → kalyugrishi.com/city-safety-score


The 6 Risk Factors It Analyzes

Unlike generic travel safety tools that give you a vague "medium risk" rating, City Safety Score breaks down the safety situation into 6 specific dimensions:

1. Active Conflict Proximity ⚔️

How close is the city to active military conflicts, war zones, or areas of armed combat? A city 200km from an active front line scores very differently from one 2,000km away.

2. Alliance and NATO Stability 🛡️

Is the country protected by a military alliance? Is that alliance stable? Countries under NATO's Article 5 protection score higher. Countries outside alliances or with deteriorating diplomatic relationships score lower.

3. Nuclear and WMD Threat Level ☢️

What is the nuclear posture of regional powers? Are there active threats or escalating rhetoric involving weapons of mass destruction? This factor analyzes the broader strategic environment.

4. Regional Geopolitical Tension 🌐

Beyond direct conflict — what is the overall temperature of the region? Diplomatic crises, contested borders, resource conflicts, and great power competition all factor into this score.

5. Economic Warfare and Sanctions 📉

Economic instability, international sanctions, currency collapse, and trade wars create dangerous environments even without direct military conflict. This factor captures that dimension.

6. Civil Unrest and Internal Stability 🏛️

Protests, government instability, ethnic tensions, coup risk, and social fragmentation affect day-to-day safety even in countries not engaged in external conflicts.


How the AI Works

City Safety Score is powered by a large language model — specifically Groq's Llama 3.3 70B — one of the most capable and fastest AI models available today.

When you enter a city and country, the AI:

  1. Draws on its training data — which includes news, geopolitical analysis, conflict reports, and diplomatic intelligence up to its knowledge cutoff
  2. Applies a structured analytical framework — the same kind of framework used by professional risk analysts and security consultants
  3. Generates calibrated scores — not random numbers, but reasoned assessments based on the geopolitical context of that specific location
  4. Writes a plain-language advisory — so you understand the situation, not just a number

The result is the kind of analysis that used to require hiring a security consulting firm — available to anyone, instantly, for free.


Real Examples — What the Scores Look Like

Kyiv, Ukraine

  • Overall score: 18/100 — Critical danger
  • Advisory: Do not travel
  • Risk flags: Active warzone, proximity to front lines, missile strike risk, infrastructure targeting
  • AI summary: Kyiv remains under active military threat with regular missile and drone strikes. Civilian infrastructure including power grids and water systems have been targeted. The city is not safe for non-essential travel under any circumstances.

Tokyo, Japan

  • Overall score: 82/100 — Relatively safe
  • Advisory: Safe to travel
  • Risk flags: Regional nuclear posture (North Korea), territorial disputes (Senkaku Islands)
  • AI summary: Tokyo is one of the world's safest major cities with strong rule of law and minimal domestic conflict risk. Regional tensions involving North Korea and China exist but do not pose an immediate threat to civilian safety in Tokyo.

Tel Aviv, Israel

  • Overall score: 31/100 — High risk
  • Advisory: Avoid non-essential travel
  • Risk flags: Active regional conflict, missile risk, escalation potential with Hezbollah and Iran
  • AI summary: Israel remains in a state of active conflict with ongoing military operations in Gaza and heightened tensions with Hezbollah in Lebanon. Tel Aviv faces periodic rocket and missile threats with significant escalation risk.

Who Should Use This Tool?

City Safety Score was built for anyone who needs to make safety decisions based on current geopolitical reality:

Travelers and tourists — before booking a flight, check the safety score of your destination. Not just the tourist board's version — the AI's honest assessment.

NRIs and Indian expats — worried about family back home or considering a new country for work? Check the score before you decide.

Students going abroad — parents sending children to universities in Europe, North America, or the Middle East can use this tool to understand the risk environment.

Business travelers — corporate professionals traveling to unfamiliar regions for meetings or projects.

Remote workers and digital nomads — choosing a base city for the next few months? Safety should be part of the decision.

Journalists and researchers — a quick reference tool for understanding the geopolitical context of a location before deeper research.


Why AI Is Better Than Traditional Safety Ratings

Traditional travel safety information has three fundamental problems:

It's slow. Government advisories are updated every few months. The world changes every few hours. An advisory written in January may not reflect the situation in July.

It's generic. "Exercise caution in Country X" tells you nothing useful. Which parts of the country? What kind of risk? What should you actually do?

It's inaccessible. Professional geopolitical risk analysis costs thousands of dollars. It's available to corporations and governments, not to the average traveler or expat.

AI changes all of this.

A large language model trained on news, intelligence reports, academic analysis, and diplomatic communications can synthesize a geopolitical picture that would take a human analyst hours — in seconds. And it can do it for anyone, for free.

City Safety Score is the first step toward democratizing geopolitical intelligence. Making the kind of analysis that used to be reserved for governments and multinationals available to every traveler with a phone.


The Technology Behind It

For the technically curious — here is the stack:

ComponentTechnology
FrontendReact + Vite
AI modelGroq Llama 3.3 70B
BackendVercel serverless functions
HostingVercel (global CDN)
PaymentsRazorpay (premium tier)
Embedded onkalyugrishi.com/safety-calculator

The AI model runs entirely server-side — your queries are processed securely and never stored. The tool works on any device, in any browser, with no installation required.


Free vs Premium

City Safety Score is free to use with 3 analyses per day — enough for most travelers planning a trip or checking a destination.

For professionals, frequent travelers, and teams who need more:

Premium — ₹99/month includes:

  • Unlimited daily analyses
  • Compare multiple cities side by side
  • PDF safety brief download
  • Priority AI response

What's Coming Next

This is version 1. Here's what I'm building next for City Safety Score:

  • Weekly safety alerts — get an email when the safety score of your city changes significantly
  • Country risk maps — visual map showing safety scores across an entire region
  • Historical score tracking — see how a city's safety score has changed over time
  • API access — for travel companies, insurance providers, and corporate travel teams

Try It Now

The tool is live. It's free. It takes 10 seconds.

→ kalyugrishi.com/safety-calculator

Enter any city. Any country. See what the AI says.

Then share it with someone who's planning to travel — or someone who's worried about where they are.


Connect  : 

Instagram : KalyugAI

Have a question about City Safety Score or want to see your city analyzed? Leave a comment below.

Sunday, 7 June 2026

How to Setup SSH Key Authentication in Linux (Passwordless Login)

 SSH key authentication allows you to log into a remote Linux server without typing a password every time. It is more secure and widely used in DevOps environments.


Step 1: Generate SSH Key Pair

Run this command on your local machine:

ssh-keygen -t rsa -b 4096

Press Enter for all prompts. This will create:

  • Private key: ~/.ssh/id_rsa
  • Public key: ~/.ssh/id_rsa.pub

Step 2: Copy Public Key to Server

Use:

ssh-copy-id user@server_ip

Example:

ssh-copy-id ubuntu@192.168.1.10

Step 3: Test SSH Login

ssh user@server_ip

You should now login without password.


Common Issue

If login still asks password, check:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Conclusion

SSH key authentication is the foundation of secure Linux server access and DevOps automation.

Friday, 5 June 2026

🧠 AI for DevOps Engineers: Real Use Cases That Are Changing Incident Management

 

🔥 Introduction

DevOps engineering is evolving rapidly.

Teams are no longer just managing infrastructure — they are now expected to integrate AI into their workflows.

But the real question is:

How is AI actually used in DevOps in real production systems?

This article explains practical, real-world use cases of AI in DevOps engineering.


⚠️ The Problem in Modern DevOps Teams

Most DevOps and SRE teams face:

  • Slow incident resolution (high MTTR)
  • Repeated production issues
  • Lack of structured debugging workflows
  • Knowledge trapped in senior engineers
  • Alert fatigue from monitoring tools

👉 Result: teams stay reactive instead of proactive.


🚀 Real Use Cases of AI in DevOps

1. 🧠 AI Incident Root Cause Analysis

AI can analyze:

  • Logs
  • Error traces
  • System metrics

And suggest:

  • Likely root cause
  • Similar past incidents
  • Probable fix

👉 This reduces debugging time drastically.


2. ⚡ AI-Powered Incident Summarization

Instead of reading thousands of logs:

AI can generate:

  • Incident summary
  • Timeline of failure
  • Key anomalies

👉 Helps engineers understand issues in minutes.


3. 🔍 Log Analysis + Pattern Detection

AI can detect patterns like:

  • Memory leaks
  • CPU spikes
  • API failure patterns
  • Database bottlenecks

👉 Something humans often miss during pressure.


4. 🛠 AI for Postmortem Generation

AI can automatically generate:

  • Incident report
  • Root cause analysis
  • Action items
  • Preventive measures

👉 Saves hours of manual documentation.


5. 🚨 Smart Alert Filtering

AI can reduce alert noise by:

  • Grouping related alerts
  • Filtering false positives
  • Highlighting critical issues only

6. 📚 AI Knowledge Assistant for DevOps Teams

AI can act as:

  • Internal documentation assistant
  • Runbook helper
  • Troubleshooting guide

👉 Reduces dependency on senior engineers.


💡 Why AI is Critical for DevOps Today

Because modern systems are:

  • Distributed
  • Complex
  • Highly dynamic

Manual debugging is no longer scalable.

AI helps engineers:

  • Reduce MTTR
  • Improve reliability
  • Automate repetitive debugging tasks

🚀 Practical Example: AI in Incident Debugging

Instead of:

Searching logs manually for hours

AI workflow:

  1. Input incident logs
  2. AI analyzes patterns
  3. Suggests probable cause
  4. Provides fix steps

👉 Result: faster resolution + less downtime


🧠 Final Thoughts

AI is not replacing DevOps engineers.

It is making them:

Faster, smarter, and more efficient.


📦 Build Your Own AI DevOps System

If you want a working implementation of AI in DevOps workflows:

👉 Check out ResolvAI
https://kalyugrishi.gumroad.com/l/resolveai


AI in DevOps, DevOps AI tools, SRE automation, incident management AI, reduce MTTR, DevOps AI assistant, AI incident response system, ChatGPT for DevOps

🚀 ResolvAI – AI Incident Copilot for DevOps Engineers (Reduce MTTR with AI)

 

🔥 “Company asked you to implement AI in DevOps? Start here.”

Most DevOps engineers today are hearing the same thing:

“We need to use AI in our engineering workflows.”

But nobody explains:

  • What to build
  • How to start
  • Or what “AI in DevOps” actually means

So engineers end up stuck between:

  • ChatGPT experiments
  • Random automation scripts
  • Tool evaluations that never go to production

Meanwhile, production incidents are still handled manually.


⚠️ The Real Problem in DevOps Teams

Modern engineering teams struggle with:

  • ⏱️ Slow incident resolution (high MTTR)
  • 📉 Lack of structured debugging flow
  • 🧠 Knowledge trapped in senior engineers’ minds
  • 🔍 Logs scattered across multiple systems
  • 🚨 Pressure to “use AI” without clear implementation path

👉 Result:
Teams stay reactive instead of becoming AI-enabled.


🚀 Introducing ResolvAI

ResolvAI is an AI-powered Incident Copilot for DevOps & SRE teams.

It helps engineers:

  • Understand production incidents faster
  • Identify probable root causes
  • Match similar past incidents
  • Suggest debugging steps
  • Reduce MTTR using AI assistance

Think of it as:

“ChatGPT + DevOps Incident Intelligence System”


🧠 What Makes ResolvAI Different?

Unlike basic AI chat tools, ResolvAI is designed specifically for:

  • Incident workflows
  • Logs + debugging context
  • DevOps pipelines
  • Real engineering operations

It is NOT just a chatbot.

It is an engineering assistant for production systems.


⚙️ How It Works

The system follows a simple flow:

🧩 Incident Flow:

  1. Input incident (logs / Jira / error description)
  2. AI processes context
  3. Matches similar past incidents
  4. Identifies probable root cause
  5. Suggests step-by-step resolution

🧱 Architecture Overview

ResolvAI is built with 4 core layers:

1. Input Layer

  • Logs
  • Jira tickets
  • Slack alerts

2. AI Processing Layer

  • LLM-based reasoning engine
  • Prompt orchestration

3. Memory Layer

  • Past incident database
  • Pattern matching system

4. Output Layer

  • Root cause prediction
  • Debugging steps
  • Resolution guidance

👥 Who Should Use ResolvAI?

  • DevOps Engineers
  • SRE Engineers
  • Platform Engineers
  • Backend Engineers
  • Engineering Managers
  • Teams adopting AI in workflows

💡 Why This Matters

If your team spends:

  • Hours debugging incidents
  • Repeating the same issues
  • Searching logs manually

Then AI can reduce:

👉 MTTR (Mean Time To Resolution)
👉 Engineering burnout
👉 Production downtime


🚀 What You Get Inside ResolvAI Starter Kit

✔ Full setup guide
✔ Working AI DevOps system
✔ Architecture breakdown
✔ Streamlit application
✔ GitHub implementation
✔ Real-world DevOps workflow design


📦 Get ResolvAI Starter Kit

This is a production-style DevOps AI system designed for learning and pilot implementation.

👉 https://kalyugrishi.gumroad.com/l/resolveai

For setup support or enterprise collaboration:

⚠️ Important Note

ResolvAI is an early-stage implementation system designed for:

  • Learning
  • Prototyping
  • Pilot deployments
  • AI adoption in DevOps teams

💰 Optional: Setup & Integration Support

If you want help implementing ResolvAI in your team:

  • Starter Setup 
  • Guided Setup 
  • Enterprise Integration

Custom DevOps AI solutions also available.


📩 Contact

📧 Email: kalyugrishiai@gmail.com
📸 Instagram: @kalyugAI

This guide helps DevOps and SRE engineers explore:
AI in DevOps, DevOps AI tools, SRE automation, incident management AI systems, how to reduce MTTR using AI, DevOps AI assistants, AI-based incident response systems, and ChatGPT for DevOps workflows.

Saturday, 26 April 2025

Top 10 Linux Commands Every DevOps Engineer Should Master in 2025

 Learning the basics of Linux is now essential in the quickly changing field of DevOps.
Linux skills are essential for a successful DevOps career, whether you're managing cloud-native environments, automating infrastructure, or deploying containerised apps.


The top ten Linux commands that every DevOps engineer needs to know by 2025 are as follows:

 

1. top — Monitor Real-Time Processes

Stay on top of your system’s CPU and memory usage.

2. grep — Search Like a Pro

From scanning massive log files to debugging issues, grep is your best friend.

3. ssh — Secure Remote Management

Mastering ssh is crucial for managing VMs, Kubernetes nodes, and cloud servers securely.

4. rsync — Efficient File Syncing

rsync lets you transfer and back up massive datasets with minimal downtime.

5. systemctl — Managing Services

Handling systemd services is critical when deploying apps on Linux VMs and bare-metal servers.

6. journalctl — Digging into System Logs

When a container crashes or a deployment fails, journalctl helps you uncover the root cause fast.

7. docker — The DevOps Superpower

Knowing your way around basic docker CLI commands is non-negotiable in today’s DevOps world.

8. kubectl — Kubernetes at Your Fingertips

From scaling pods to debugging clusters, kubectl is your go-to tool.

9. vim or nano — Editing on the Go

A true DevOps engineer should never fear quick config edits inside a production server.

10. curl — API Debugging Made Easy

Testing endpoints, health checks, or automation scripts?
curl remains the unsung hero of DevOps workflows.


#DevOps2025 #LinuxCommands #DevOpsEngineerRoadmap #CloudComputing #Kubernetes #LinuxForDevOps #DevOpsTools


 

Tuesday, 9 July 2024

Getting Started with Docker: Beginner’s Guide

Getting Started with Docker

 Docker simplifies the process of creating, deploying, and running applications by using containerization.

What is Docker?

Docker is an open-source platform designed to automate the deployment of applications inside lightweight, portable containers. Containers encapsulate an application and its dependencies, ensuring that it runs consistently across different environments.

Key Concepts

Before diving into practical steps, let’s understand some key Docker concepts: - Images: Read-only templates that define how a container should be instantiated. They include everything needed to run an application (code, runtime, libraries, etc.). - Containers: Instances of Docker images that run as isolated processes in user space on the host operating system. - Dockerfile: A script containing instructions on how to build a Docker image. - Docker Hub: A cloud-based registry service for sharing Docker images.

Installation 

To start using Docker, you need to install Docker Desktop on your machine. Follow these steps based on your operating system: Windows and macOS

 1. Download Docker Desktop:

 - Visit the Docker Desktop download page and download the installer for your operating system.

 2. Install Docker Desktop:

 - Run the installer and follow the on-screen instructions.

 3. Verify Installation:

 - Open a terminal or command prompt and run: docker --version - You should see the installed Docker version. Linux

 1. Install Docker Engine: - Follow the official installation guide for Docker Engine based on your Linux distribution. 2. Verify Installation: - Open a terminal and run: docker --version - You should see the installed Docker version.

Your First Docker Container

Let’s create a simple Docker container running an Nginx web server. 1. Pull the Nginx Image:

 - Open a terminal and run: docker pull nginx - This command pulls the Nginx image from Docker Hub to your local machine.

 2. Run the Nginx Container:

 - Start an Nginx container using the pulled image: docker run --name my-nginx -p 8080:80 -d nginx - This command runs the Nginx container, names it my-nginx, maps port 80 of the container to port 8080 of the host, and runs it in detached mode.

 3. Verify the Nginx Container:

 - Open a web browser and navigate to http://localhost:8080. - You should see the Nginx welcome page.

Dockerfile Basics

 A Dockerfile is a script containing instructions to build a Docker image. Let’s create a Dockerfile for a simple Node.js application. 1. Set Up the Project Directory: - Create a new directory for your project and navigate into it: mkdir my-node-app cd my-node-app

 2. Create a Node.js Application: - Initialize a new Node.js project and install Express: npm init -y npm install express - Create an index.js file with the following content: const express = require('express'); const app = express(); const port = 3000; app.get('/', (req, res) => { res.send('Hello, Docker!'); }); app.listen(port, () => { console.log(`App running at http://localhost:${port}`); });

 3. Create a Dockerfile: - In the same directory, create a file named Dockerfile with the following content: # Use the official Node.js image as the base image FROM node:14 # Set the working directory WORKDIR /usr/src/app # Copy package.json and package-lock.json COPY package*.json ./ # Install dependencies RUN npm install # Copy the rest of the application code COPY . . # Expose the application port EXPOSE 3000 # Command to run the application CMD ["node", "index.js"] 4. Build the Docker Image: - Build the image from the Dockerfile: docker build -t my-node-app .

 5. Run the Docker Container: - Start a container from the built image: docker run -p 3000:3000 my-node-app

 6. Verify the Application: - Open a web browser and navigate to http://localhost:3000. - You should see the message "Hello, Docker!" Managing Docker Containers Here are some useful commands to manage Docker containers: - List Running Containers: docker ps Shows all running containers.

 - Stop a Container: docker stop <container_id> Stops the specified container.

 - Remove a Container: docker rm <container_id> Removes the specified container.

 - List Docker Images: docker images Lists all Docker images on your local machine.

 - Remove a Docker Image: docker rmi <image_id> Removes the specified Docker image. Happy Dockerizing!

Getting Started With Terraform

 Let’s create a simple Terraform configuration to launch an EC2 instance on AWS on a Linux VM.

 

1. Set Up AWS Provider: 

 On shell - 

 

mkdir my-terraform-project
cd my-terraform-project

 

 Create a file named main.tf and add the following content: 

 

provider "aws" {
region = "us-west-2"
}

 

2. Define an EC2 Instance Resource:

In the same main.tf file, add the following resource definition:


resource "aws_instance" "example" {
ami = "ami-0c55b159cbfafe1f0" # Example AMI ID
instance_type = "t2.micro"

tags = {
Name = "example-instance"
}
}

 

3. Initialize Terraform:

Initialize your Terraform project, which will download the necessary provider plugins:

 
terraform init


4. Format and Validate Configuration:

Format your configuration files for readability:


terraform fmt


Validate the configuration for syntax errors:

terraform validate


5. Preview and Apply Changes:

Preview the changes Terraform will make to your infrastructure:


terraform plan


Apply the changes to create the EC2 instance:


terraform apply


When prompted, type yes to confirm.


 

6. Verify the Instance:

 

Go to the AWS Management Console and navigate to the EC2 dashboard to see your new instance running.


7. Managing State


Terraform’s state file, terraform.tfstate, keeps track of the resources it manages. This file is crucial for planning and applying changes accurately.
It’s recommended to store your state file in a remote backend (e.g., AWS S3) for collaboration and reliability.

8. Cleaning Up


To destroy the resources created by your configuration, use the destroy command:


terraform destroy


Type yes when prompted to confirm the destruction of resources.