B.E VI Semester · June 2026

DevOps Lab — Complete Answer Guide

MVSR Engineering College (A) · Department of Information Technology · U21PC683IT

📋 27 Programs
🛠️ Git · Docker · Kubernetes · Jenkins · Selenium
📅 Main Practical Exams
Jump to program:
Common to ALL 27 Programs — Q1, Q2, Q3
Git · Docker · Kubernetes Command Reference
Q1 — Five Git Commands & Usage
git initInitializes a new empty Git repository in the current directory.
git clone <url>Clones an existing remote repository to the local machine.
git add .Stages all modified and new files for the next commit.
git commit -m "msg"Records staged changes to the repository with a descriptive message.
git push origin mainPushes local commits to the remote repository branch named main.
Q2 — Five Docker Commands & Usage
docker build -t <name> .Builds a Docker image from the Dockerfile in the current directory and tags it.
docker run -d -p 8080:80 <img>Runs a container in detached mode, mapping host port 8080 to container port 80.
docker psLists all currently running containers with their IDs, names, and status.
docker imagesShows all locally available Docker images with their tags and sizes.
docker push <user/img:tag>Pushes a tagged image to Docker Hub (or another registry).
Q3 — Five Kubernetes Commands & Usage
kubectl get podsLists all pods in the default namespace with their status.
kubectl apply -f file.yamlCreates or updates resources described in a YAML manifest file.
kubectl describe pod <name>Shows detailed information about a specific pod (events, IP, containers).
kubectl delete deployment <n>Deletes a named deployment and all its associated pods.
kubectl expose deploy <n> --port=80Creates a Service to expose a deployment on the specified port.

P1Java — Build & Run Docker, Push to GitHub + DockerHub

Q4 — Java Program + Dockerfile + GitHub + DockerHub
Approach: Write a simple Java program, create a Dockerfile, build the image, push code to GitHub, push image to DockerHub.
HelloWorld.java
HelloWorld.java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello from Java Docker Container!");
    }
}
Dockerfile
Dockerfile
FROM openjdk:17-jdk-slim
WORKDIR /app
COPY HelloWorld.java .
RUN javac HelloWorld.java
CMD ["java", "HelloWorld"]
Terminal Commands
# Push code to GitHub
git init
git add .
git commit -m "Add Java HelloWorld"
git remote add origin https://github.com/<username>/java-docker.git
git push -u origin main

# Build and run Docker image locally
docker build -t java-hello .
docker run java-hello

# Push image to DockerHub
docker login
docker tag java-hello <dockerhub-username>/java-hello:latest
docker push <dockerhub-username>/java-hello:latest

P2C — Build & Run Docker, Push to GitHub + DockerHub

Q4 — C Program + Dockerfile + GitHub + DockerHub
hello.c
#include <stdio.h>
int main() {
    printf("Hello from C in Docker!\n");
    return 0;
}
Dockerfile
FROM gcc:latest
WORKDIR /app
COPY hello.c .
RUN gcc -o hello hello.c
CMD ["./hello"]
# Push code to GitHub
git init && git add . && git commit -m "C Docker app"
git remote add origin https://github.com/<username>/c-docker.git
git push -u origin main

# Build, run, push to DockerHub
docker build -t c-hello .
docker run c-hello
docker tag c-hello <dockerhub-username>/c-hello:latest
docker push <dockerhub-username>/c-hello:latest

P3HTML — Build & Run Docker, Push to GitHub + DockerHub

Q4 — HTML Page + nginx Dockerfile + GitHub + DockerHub
index.html
<!DOCTYPE html>
<html><head><title>DevOps HTML App</title></head>
<body>
  <h1>Hello from HTML in Docker!</h1>
  <p>Deployed via nginx container.</p>
</body></html>
Dockerfile
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
EXPOSE 80
docker build -t html-app .
docker run -d -p 8080:80 html-app
# Visit http://localhost:8080
docker tag html-app <user>/html-app:latest
docker push <user>/html-app:latest

P4Python — Build & Run Docker, Push to GitHub + DockerHub

Q4 — Python Program + Dockerfile
app.py
print("Hello from Python in Docker!")
name = "DevOps"
print(f"Welcome to {name} Lab")
Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY app.py .
CMD ["python", "app.py"]
docker build -t python-app .
docker run python-app
docker tag python-app <user>/python-app:latest
docker push <user>/python-app:latest

P5Node.js — Build & Run Docker, Push to GitHub + DockerHub

Q4 — Node.js App + Dockerfile
app.js
const http = require('http');
const server = http.createServer((req, res) => {
  res.end('Hello from Node.js Docker Container!\n');
});
server.listen(3000, () => console.log('Server running on port 3000'));
Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY app.js .
EXPOSE 3000
CMD ["node", "app.js"]
docker build -t node-app .
docker run -d -p 3000:3000 node-app
docker push <user>/node-app:latest

P6Flask (Python) — Build & Run Docker, Push to GitHub + DockerHub

Q4 — Flask App + Dockerfile
app.py
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return '<h1>Hello from Flask in Docker!</h1>'

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)
requirements.txt
flask
Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY app.py .
EXPOSE 5000
CMD ["python", "app.py"]
docker build -t flask-app .
docker run -d -p 5000:5000 flask-app
# Visit http://localhost:5000
docker push <user>/flask-app:latest

P7C Program → GitHub → Jenkins Job

Q4 — C Program + GitHub Push + Jenkins Freestyle Job
hello.c (same as P2)
#include <stdio.h>
int main() { printf("Hello from C!\n"); return 0; }
# Push to GitHub
git init && git add . && git commit -m "C program"
git remote add origin https://github.com/<user>/c-jenkins.git
git push -u origin main
Jenkins Freestyle Job Steps
1
Open Jenkins → New Item → Enter name C-Job → Select Freestyle project → OK
2
Under Source Code Management → Select Git → Paste your GitHub repo URL
3
Under Build Steps → Add build step → Execute shell
gcc -o hello hello.c
./hello
4
Click Save → Click Build Now → Check Console Output for result

P8Python Calculator (ADD/SUB/MUL/DIV) → GitHub → Jenkins Job

Q4 — Python Calculator + Jenkins Job
calc.py
a, b = 10, 3
print(f"ADD: {a} + {b} = {a+b}")
print(f"SUB: {a} - {b} = {a-b}")
print(f"MUL: {a} * {b} = {a*b}")
print(f"DIV: {a} / {b} = {a/b:.2f}")
Jenkins Build Shell Command
python3 calc.py
Steps: Push calc.py to GitHub → Jenkins → New Item (Freestyle) → SCM: Git (repo URL) → Build: Execute shell → python3 calc.py → Save → Build Now

P9Java — Reverse of a Number → GitHub → Jenkins Job

Q4 — Java Reverse Number + Jenkins Job
ReverseNumber.java
public class ReverseNumber {
    public static void main(String[] args) {
        int num = 12345, rev = 0;
        while (num != 0) {
            rev = rev * 10 + num % 10;
            num /= 10;
        }
        System.out.println("Reverse: " + rev);
    }
}
Jenkins Build Shell Command
javac ReverseNumber.java
java ReverseNumber

P10Docker Hello-World + Jenkins Periodic Build Trigger

Q4a — Run Hello-World in Docker
# Pull and run hello-world image
docker pull hello-world
docker run hello-world

# List all containers including stopped
docker ps -a
Q5 — Jenkins Job with Build Trigger (Periodic)
1
New Item → Shell-Job → Freestyle project → OK
2
Build Steps → Execute shell → enter: echo "Hello from Jenkins Shell" and date
3
Build Triggers → check Build periodically → Schedule:
# Build every 5 minutes:
H/5 * * * *

# Build daily at midnight:
0 0 * * *

# Build every hour:
H * * * *
4
Click Save. Jenkins will automatically trigger the job at the specified interval.

P11HTML Registration Form → GitHub → Jenkins (Publish HTML)

Q4 — Registration Form + Jenkins HTML Publisher
registration.html
<!DOCTYPE html>
<html><head><title>Registration</title></head>
<body>
  <h2>Student Registration Form</h2>
  <form>
    <label>Name: <input type="text" name="name"></label><br><br>
    <label>Email: <input type="email" name="email"></label><br><br>
    <label>Phone: <input type="tel" name="phone"></label><br><br>
    <input type="submit" value="Register">
  </form>
</body></html>
Jenkins Steps (install HTML Publisher plugin first)
1
Manage Jenkins → Plugins → Install HTML Publisher Plugin
2
New Item → HTML-Publish-Job → Freestyle → SCM: Git (your repo)
3
Post-build Actions → Publish HTML reports → HTML directory: ., Index: registration.html
4
Save → Build Now → Click "HTML Report" link in job page

P12Jenkins Pipeline Job using Jenkinsfile (SCM – Git)

Q4 — Jenkins Pipeline via Jenkinsfile stored in Git
Jenkinsfile
pipeline {
    agent any
    stages {
        stage('Checkout') {
            steps { checkout scm }
        }
        stage('Build') {
            steps { echo 'Building the application...' }
        }
        stage('Test') {
            steps { echo 'Running tests...' }
        }
        stage('Deploy') {
            steps { echo 'Deploying...' }
        }
    }
    post {
        always { echo 'Pipeline complete!' }
    }
}
1
Push Jenkinsfile to your GitHub repository root
2
Jenkins → New Item → Pipeline → OK
3
Pipeline → Definition: Pipeline script from SCM → SCM: Git → Repo URL → Branch: main
4
Script Path: Jenkinsfile → Save → Build Now

P13Java & Python Pattern Display → Jenkins (File Parameterization)

Q4 — Pattern Programs + Jenkins with File Parameter
Pattern.java
public class Pattern {
    public static void main(String[] args) {
        int n = 5;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) System.out.print("* ");
            System.out.println();
        }
    }
}
pattern.py
n = 5
for i in range(1, n+1):
    print('* ' * i)
Jenkins File Parameterization Steps
1
New Item → Pattern-Job → Freestyle → Check This project is parameterized
2
Add Parameter → File Parameter → File location: script_file
3
Build step → Execute shell:
# Detect and run based on uploaded file extension
if [ -f "script_file" ]; then
  if python3 -c "import py_compile; py_compile.compile('script_file')" 2>/dev/null; then
    python3 script_file
  else
    javac script_file && java $(basename script_file .java)
  fi
fi

P14Run Ubuntu Container + Jenkins 5-Stage Pipeline

Q4 — Docker Ubuntu Container Named "MyContainer"
# Pull Ubuntu image
docker pull ubuntu

# Run named container interactively
docker run -it --name MyContainer ubuntu /bin/bash

# Inside container — execute shell commands:
ls
pwd
echo "Hello from MyContainer"
cat /etc/os-release
exit

# From host — see all containers
docker ps -a
Q5 — Jenkins Pipeline with 5 Stages
Jenkinsfile
pipeline {
    agent any
    stages {
        stage('Stage 1: Checkout') {
            steps { echo 'Checking out source code' }
        }
        stage('Stage 2: Build') {
            steps { echo 'Building the project' }
        }
        stage('Stage 3: Test') {
            steps { echo 'Running unit tests' }
        }
        stage('Stage 4: Package') {
            steps { echo 'Packaging the application' }
        }
        stage('Stage 5: Deploy') {
            steps { echo 'Deploying to server' }
        }
    }
}

P15Python Docker Commands + Kubernetes nginx Deployment

Q4 — Run Python Image & Execute Commands
# Pull and run Python image interactively
docker pull python:3.11-slim
docker run -it python:3.11-slim /bin/sh

# Inside container:
python3 --version
python3 -c "print('Hello from Python Container')"
python3 -c "import sys; print(sys.version)"
exit
Q5 — Kubernetes nginx Deployment
# Create nginx deployment
kubectl create deployment nginx-deploy --image=nginx

# Scale to 3 replicas
kubectl scale deployment nginx-deploy --replicas=3

# Expose as a service
kubectl expose deployment nginx-deploy --port=80 --type=NodePort

# Run kubectl commands
kubectl get deployments
kubectl get pods
kubectl get services
kubectl describe deployment nginx-deploy

P16Node Docker Commands + Kubernetes Python Deployment

Q4 — Run Node Image & Execute Commands
docker pull node:18-alpine
docker run -it node:18-alpine /bin/sh

# Inside container:
node --version
node -e "console.log('Hello from Node Container')"
node -e "console.log(2+3)"
exit
Q5 — Kubernetes Python Deployment
kubectl create deployment python-deploy --image=python:3.11-slim \
  -- python3 -c "import time; [print('running',i) or time.sleep(5) for i in range(100)]"
kubectl scale deployment python-deploy --replicas=2
kubectl get pods
kubectl get deployments
kubectl describe deployment python-deploy
kubectl logs <pod-name>

P17nginx Docker Commands + Kubernetes Mongo Deployment

Q4 — Run nginx Image & Execute Commands
docker pull nginx
docker run -d --name mynginx -p 8080:80 nginx
docker exec -it mynginx /bin/bash

# Inside container:
nginx -v
ls /usr/share/nginx/html
cat /etc/nginx/nginx.conf
exit

docker stop mynginx
docker rm mynginx
Q5 — Kubernetes MongoDB Deployment
kubectl create deployment mongo-deploy --image=mongo:latest
kubectl expose deployment mongo-deploy --port=27017
kubectl get deployments
kubectl get pods
kubectl get services
kubectl describe deployment mongo-deploy
kubectl logs <mongo-pod-name>

P18Containerized HTML Registration App → DockerHub + GitHub

Q4 — HTML Registration App in Docker + Push to DockerHub & GitHub
Same HTML registration form from Program 11. Wrap it with nginx in Docker.
# File structure:
registration-app/
  ├── index.html     (registration form)
  └── Dockerfile
Dockerfile
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
EXPOSE 80
# Push code to GitHub
git init && git add . && git commit -m "HTML registration app"
git remote add origin https://github.com/<user>/registration-app.git
git push -u origin main

# Build, run, push to DockerHub
docker build -t registration-app .
docker run -d -p 8080:80 registration-app
docker login
docker tag registration-app <user>/registration-app:latest
docker push <user>/registration-app:latest

P19Docker Compose — Two busybox Containers, Ping between them

Q4 — Docker Compose busybox ping
docker-compose.yml
version: '3'
services:
  bbConA:
    image: busybox
    container_name: bbConA
    command: sh -c "sleep 3600"
    networks:
      - mynet

  bbConB:
    image: busybox
    container_name: bbConB
    command: sh -c "sleep 3600"
    networks:
      - mynet

networks:
  mynet:
    driver: bridge
# Start both containers
docker-compose up -d

# Verify both are running
docker ps

# Ping bbConB from bbConA
docker exec bbConA ping -c 4 bbConB

# Stop containers
docker-compose down

P20Kubernetes — nginx Deployment using YAML Manifest Files

Q4 — nginx Deployment + Service via YAML
nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
nginx-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
  type: NodePort
# Apply manifests
kubectl apply -f nginx-deployment.yaml
kubectl apply -f nginx-service.yaml

# Verify
kubectl get deployments
kubectl get pods
kubectl get services
kubectl describe deployment nginx-deployment

P21Kubernetes Node Deployment + Selenium — Open Google/College Website

Q4 — Kubernetes Node Deployment
kubectl create deployment node-deploy --image=node:18-alpine \
  -- node -e "setInterval(()=>console.log('Node running'),5000)"
kubectl get deployments
kubectl get pods
kubectl expose deployment node-deploy --port=3000
kubectl logs <pod-name>
Q5 — Selenium: Open Google in Browser (JavaScript)
Setup: Install Node.js, then run: npm install selenium-webdriver. Download ChromeDriver matching your Chrome version.
openGoogle.js
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

(async function main() {
    let driver = await new Builder()
        .forBrowser('chrome')
        .build();
    try {
        await driver.get('https://www.google.com');
        console.log('Title:', await driver.getTitle());
        await driver.sleep(3000);
    } finally {
        await driver.quit();
    }
})();
node openGoogle.js

P22Selenium — Login Validation Application

Q4 — Login Validation with Selenium (JavaScript)
login.html (test page)
<!DOCTYPE html><html><body>
<form id="loginForm">
  <input type="text" id="username" placeholder="Username">
  <input type="password" id="password" placeholder="Password">
  <button type="button" onclick="validate()">Login</button>
</form>
<p id="msg"></p>
<script>
  function validate() {
    var u = document.getElementById('username').value;
    var p = document.getElementById('password').value;
    document.getElementById('msg').innerText =
      (u==='admin' && p==='1234') ? 'Login Successful!' : 'Invalid Credentials';
  }
</script></body></html>
loginTest.js
const { Builder, By } = require('selenium-webdriver');
const path = require('path');

(async function () {
    let driver = await new Builder().forBrowser('chrome').build();
    try {
        await driver.get('file://' + path.resolve('login.html'));

        // Test 1: Valid login
        await driver.findElement(By.id('username')).sendKeys('admin');
        await driver.findElement(By.id('password')).sendKeys('1234');
        await driver.findElement(By.css('button')).click();
        let msg = await driver.findElement(By.id('msg')).getText();
        console.log('Test 1:', msg);

        // Test 2: Invalid login
        await driver.findElement(By.id('username')).clear();
        await driver.findElement(By.id('password')).clear();
        await driver.findElement(By.id('username')).sendKeys('wrong');
        await driver.findElement(By.id('password')).sendKeys('bad');
        await driver.findElement(By.css('button')).click();
        msg = await driver.findElement(By.id('msg')).getText();
        console.log('Test 2:', msg);
    } finally {
        await driver.quit();
    }
})();

P23Selenium — Check Exam Results on College Website

Q4 — Selenium: Open College Result Portal (JavaScript)
examResult.js
const { Builder, By, until } = require('selenium-webdriver');

(async function () {
    let driver = await new Builder().forBrowser('chrome').build();
    try {
        // Open college result website
        await driver.get('https://matrusri.skolo.in/');

        // Wait for page to load
        await driver.wait(until.titleContains(''), 10000);

        // Print page title
        let title = await driver.getTitle();
        console.log('Page Title:', title);

        // Get current URL
        let url = await driver.getCurrentUrl();
        console.log('Current URL:', url);

        // Take screenshot
        let img = await driver.takeScreenshot();
        require('fs').writeFileSync('result.png', img, 'base64');
        console.log('Screenshot saved as result.png');

        await driver.sleep(3000);
    } finally {
        await driver.quit();
    }
})();
node examResult.js

P24Calculator Web App + Selenium Test Cases

Q4 — Calculator Web App
calculator.html
<!DOCTYPE html><html><head><title>Calculator</title></head><body>
<h2>Calculator</h2>
<input type="number" id="a" placeholder="Number 1">
<input type="number" id="b" placeholder="Number 2"><br><br>
<button onclick="calc('add')">ADD</button>
<button onclick="calc('sub')">SUB</button>
<button onclick="calc('mul')">MUL</button>
<button onclick="calc('div')">DIV</button>
<p id="result"></p>
<script>
function calc(op){
  var a=+document.getElementById('a').value, b=+document.getElementById('b').value, r;
  if(op==='add') r=a+b; else if(op==='sub') r=a-b;
  else if(op==='mul') r=a*b; else r = b?a/b:'Error';
  document.getElementById('result').innerText='Result: '+r;
}
</script></body></html>
calcTest.js
const { Builder, By } = require('selenium-webdriver');
const path = require('path');

(async function () {
    let driver = await new Builder().forBrowser('chrome').build();
    try {
        await driver.get('file://' + path.resolve('calculator.html'));

        async function test(btnText, a, b, expected) {
            let inA = driver.findElement(By.id('a'));
            let inB = driver.findElement(By.id('b'));
            await inA.clear(); await inA.sendKeys(String(a));
            await inB.clear(); await inB.sendKeys(String(b));
            await driver.findElement(By.xpath(`//button[text()='${btnText}']`)).click();
            let res = await driver.findElement(By.id('result')).getText();
            console.log(`${btnText}(${a},${b}) → ${res} | Expected: Result: ${expected}`);
        }

        await test('ADD', 10, 5, 15);
        await test('SUB', 10, 5, 5);
        await test('MUL', 10, 5, 50);
        await test('DIV', 10, 5, 2);
    } finally {
        await driver.quit();
    }
})();

P25Jenkins — Execute Java from GIT, Build Remotely

Q4 — Jenkins Job: Java from GitHub + Remote Build Trigger
Push a Java program to GitHub. Create a Jenkins Freestyle Job. Enable remote build trigger with an auth token.
# Push Java program (use HelloWorld.java or ReverseNumber.java) to GitHub first
git push -u origin main
Jenkins Configuration Steps
1
New Item → Java-Remote-Job → Freestyle → OK
2
SCM → Git → Repo URL (GitHub) → Branch: main
3
Build Triggers → check Trigger builds remotely → Authentication Token: mytoken123
4
Build → Execute shell:
javac HelloWorld.java
java HelloWorld
5
Save. Trigger remotely using:
# Trigger from curl (remote build URL):
curl http://<jenkins-url>/job/Java-Remote-Job/build?token=mytoken123

# With auth if Jenkins security enabled:
curl -u username:api-token \
  http://<jenkins-url>/job/Java-Remote-Job/build?token=mytoken123

P26Jenkins — Python Calculator from GIT, SCM Polling Auto-Trigger

Q4 — Jenkins Job with SCM Polling (auto-execute when code changes)
Uses the calc.py file from Program 8. Push it to GitHub. Configure Jenkins to poll GitHub and auto-build on changes.
Jenkins Configuration
1
New Item → Python-SCM-Job → Freestyle → OK
2
SCM → Git → GitHub Repo URL → Branch: main
3
Build Triggers → check Poll SCM → Schedule:
# Poll every minute (checks GitHub for new commits)
* * * * *

# Poll every 5 minutes
H/5 * * * *
4
Build → Execute shell: python3 calc.py
5
Save. Now when you push a new commit to GitHub, Jenkins will detect it within the poll interval and automatically run the job.

P27Java & Python Calculator → Jenkins (File + Variable Parameterization)

Q4 — Calculator Programs + Jenkins with File & Variable Parameters
Calculator.java
public class Calculator {
    public static void main(String[] args) {
        int a = 20, b = 4;
        System.out.println("ADD: " + (a+b));
        System.out.println("SUB: " + (a-b));
        System.out.println("MUL: " + (a*b));
        System.out.println("DIV: " + (a/b));
    }
}
calc.py (same as P8)
a, b = 20, 4
print(f"ADD: {a+b}"); print(f"SUB: {a-b}")
print(f"MUL: {a*b}"); print(f"DIV: {a/b}")
Jenkins: File + Variable Parameterization
1
New Item → Calc-Param-Job → Freestyle → Check This project is parameterized
2
Add Parameter → Choice Parameter: Name = LANG, Choices = Java and Python
3
Add Parameter → File Parameter: File location = uploaded_script
4
Build → Execute shell:
# Use the LANG variable to decide which runner to use
if [ "$LANG" = "Python" ]; then
  python3 uploaded_script
else
  # Java: rename and compile
  cp uploaded_script Calculator.java
  javac Calculator.java
  java Calculator
fi
5
Save → Click Build with Parameters → Select language, upload script file → Build
MVSR Engineering College (A) · DevOps Lab U21PC683IT · B.E VI Semester · June 2026