0.1 Why DevOps after (or beside) AWS
Why: the problem
You finished the AWS course. You can start an EC2 server, open a port and attach an IAM role. Good. Now think of a real team at Swiggy. Developers change the menu service twenty times a day. If each change needs a person to log in to a server, copy files and restart the app, that person becomes the slowest part of the company. Mistakes happen too: a wrong file, a missed step, a server that is different from the others. AWS gives you the servers. DevOps is how you ship changes to those servers safely, quickly and the same way every time. It is a way of working plus a set of tools: Git to track changes, Docker to package the app, CI/CD to build and test it automatically, Terraform to create servers from code, Kubernetes to run many copies, and monitoring to know when something breaks. In this lesson you will feel the difference yourself. You will deploy a tiny web page by hand, then deploy it again with a script and with Docker, and count the steps and the mistakes.
What we will build
You will put a one-line web page on a Linux machine three ways. First by hand, typing every step. Second with a small Bash script that does the same steps. Third with a Docker container that carries the page and the web server together. At the end you will compare: how many commands, how long, and how easy it is to repeat on a second machine.
What: every term in plain English
- AWS — Amazon Web Services. It rents you servers, storage and networks by the hour.
- DevOps — A way of working where the people who write code and the people who run it share the work, and automate the boring, risky steps.
- Deploy — Putting a new version of the app on the server so users get it.
- Manual deploy — A human types every step. Slow and easy to get wrong.
- Script — A text file with commands. The computer runs them in order, the same way every time.
- Container — A package with the app and everything it needs, so it runs the same on every machine.
- Repeatable — You can do it again and get the same result.
- nginx — A popular, free web server. It sends web pages to browsers.
How: step by step
-
Make your lab folder
mkdir -p ~/devops-lab && cd ~/devops-lab && pwdWhat it does: One folder for every lab in this course. Easy to find, easy to clean.
Output
/home/ravi/devops-lab -
Install nginx by hand
sudo apt update && sudo apt install -y nginxWhat it does: Downloads the package list, then installs the nginx web server.
Output
Reading package lists... Done Setting up nginx (1.18.0-6ubuntu14.4) ... Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service -
Write the page by hand
echo "Swiggy menu v1" | sudo tee /var/www/html/index.htmlWhat it does: Puts one line of text into the default web page file.
Output
Swiggy menu v1 -
Start nginx
sudo systemctl enable --now nginxWhat it does: Starts nginx now and also at every boot.
Output
(no output means it worked) -
Open the page
curl -s localhostWhat it does: Asks the local web server for the page, like a browser would.
Output
Swiggy menu v1 -
Count what you did
history | tail -5What it does: Shows your last commands. Each one is a step a human can forget.
Output
101 sudo apt update && sudo apt install -y nginx 102 echo "Swiggy menu v1" | sudo tee /var/www/html/index.html 103 sudo systemctl enable --now nginx 104 curl -s localhost
Example 1: Deploy by hand and time it
Stack. Ubuntu 22.04, nginx 1.18
Goal. Deploy by hand and time it. This is the "old way".
terminal
time (
sudo apt install -y nginx
echo "Swiggy menu v2" | sudo tee /var/www/html/index.html
sudo systemctl restart nginx
curl -s localhost
)
What each line does
time ( ... )— Runs everything inside the brackets and prints how long it took.apt install -y nginx— Installs nginx. -y says yes to the question.tee /var/www/html/index.html— Writes the new page. sudo is needed because the folder belongs to root.systemctl restart nginx— Restarts the web server so it serves the new file.curl -s localhost— Checks the page. -s hides the progress bar.
Green output
nginx is already the newest version (1.18.0-6ubuntu14.4).
Swiggy menu v2
Swiggy menu v2
real 0m2.418s
user 0m0.512s
sys 0m0.210s
Expected result. It works, but only because you typed four lines correctly. On ten servers you would type forty lines.
Example 2: The same deploy as a Bash script
Stack. Bash 5, Ubuntu 22.04
Goal. The same deploy as a Bash script. This is the first step of automation.
deploy.sh
#!/usr/bin/env bash
set -euo pipefail
VERSION="${1:-v3}"
sudo apt-get install -y nginx > /dev/null
echo "Swiggy menu ${VERSION}" | sudo tee /var/www/html/index.html > /dev/null
sudo systemctl restart nginx
if curl -s localhost | grep -q "${VERSION}"; then
echo "DEPLOY OK: ${VERSION}"
else
echo "DEPLOY FAILED" && exit 1
fi
terminal
chmod +x deploy.sh
./deploy.sh v3
What each line does
#!/usr/bin/env bash— Tells Linux to run this file with Bash.set -euo pipefail— Stop at the first error. Do not continue half done.VERSION="${1:-v3}"— Takes the version from the first argument, or uses v3.> /dev/null— Hides noisy output so you see only the result.grep -q "${VERSION}"— Checks that the new version is really being served.exit 1— Marks the script as failed so a person or a tool notices.chmod +x deploy.sh— Makes the file runnable by you..
Green output
DEPLOY OK: v3
Expected result. One command now does the whole deploy and checks itself. A teammate can run the same file and get the same result.
Example 3: The same page in a Docker container
Stack. Docker 26, nginx 1.27-alpine
Goal. The same page in a Docker container. The app and the server travel together.
Dockerfile
FROM nginx:1.27-alpine
COPY index.html /usr/share/nginx/html/index.html
index.html
Swiggy menu v4 (from a container)
terminal
sudo systemctl stop nginx
docker build -t menu:v4 .
docker run -d --name menu -p 80:80 menu:v4
curl -s localhost
What each line does
FROM nginx:1.27-alpine— Start from the official small nginx image, pinned to a version.COPY index.html ...— Put our page inside the image.systemctl stop nginx— Frees port 80 that the host nginx was using.docker build -t menu:v4 .— Builds an image named menu with tag v4 from this folder.docker run -d -p 80:80— Runs it in the background. Host port 80 goes to container port 80.curl -s localhost— Checks the page from the container.
Green output
[+] Building 3.1s (7/7) FINISHED
=> naming to docker.io/library/menu:v4
3f1c9a7e2b...
Swiggy menu v4 (from a container)
Expected result. The image menu:v4 runs the same on your laptop, on EC2 or on a teammate's machine. This is why every DevOps chapter after this uses containers.
Verify: did it work?
-
Check the container is up
docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}"What it does: Shows the running container and its image.
Output
NAMES IMAGE STATUS menu menu:v4 Up 20 seconds -
Compare the three ways
wc -l deploy.sh DockerfileWhat it does: Counts lines. Fewer, tested lines mean fewer mistakes.
Output
11 deploy.sh 2 Dockerfile 13 total
When it is red 1
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Cause. Something else already uses port 80, often the host nginx or an old container.
Fix, step by step
- Run sudo ss -ltnp | grep :80 to see who uses it.
- Stop it: sudo systemctl stop nginx or docker rm -f menu.
- Start your web server again.
When it is red 2
tee: /var/www/html/index.html: Permission denied
Cause. You wrote to a root folder without sudo.
Fix, step by step
- Put sudo before tee, not before echo.
- Run the command again.
- Never open the folder to everyone; use sudo for this one write.
When it is red 3
docker: permission denied while trying to connect to the Docker daemon socket
Cause. Your user is not in the docker group yet.
Fix, step by step
- Run sudo usermod -aG docker $USER.
- Log out and log in again (or run newgrp docker).
- Run docker ps to check.
Cleanup
-
Remove the container
docker rm -f menuWhat it does: Stops and deletes the container.
Output
menu -
Remove the image
docker rmi menu:v4What it does: Deletes the image you built.
Output
Untagged: menu:v4 Deleted: sha256:3f1c9a7e2b... -
Stop host nginx
sudo systemctl disable --now nginxWhat it does: Stops nginx and keeps it off after reboot.
Output
Removed /etc/systemd/system/multi-user.target.wants/nginx.service.
Ravindra Bagale's Tip
AWS is the house (the server). DevOps is the habit of keeping that house clean every day. First do it by hand, then write a script, then use a container. Feel the difference yourself!
AWS म्हणजे घर (server), DevOps म्हणजे घर रोज साफ आणि व्यवस्थित ठेवायची पद्धत. आधी हाताने करा, मग script, मग container. फरक स्वतः अनुभवा!
AWS यानी घर (server), DevOps यानी घर रोज़ साफ़ और व्यवस्थित रखने की आदत. पहले हाथ से करो, फिर script, फिर container. फर्क खुद महसूस करो!
Practice tasks
Easy Change the version
Why: Small change, full deploy. That is daily DevOps work.
What to do: Run ./deploy.sh v9 and check the page.
- ./deploy.sh v9
- curl -s localhost
Check: The page says Swiggy menu v9.
Medium Make the script fail on purpose
Why: A good script must say FAILED loudly.
What to do: Edit deploy.sh so the grep looks for a wrong word, then run it.
- Change grep to look for "xyz".
- Run ./deploy.sh.
- echo $? should print 1.
Check: You see DEPLOY FAILED and exit code 1.
Hard Two containers, two versions
Why: Teams often run old and new side by side.
What to do: Run menu:v4 on port 8081 and a new menu:v5 on port 8082.
- Build menu:v5 with new text.
- docker run -d -p 8081:80 menu:v4 and -p 8082:80 menu:v5.
- curl both ports.
Check: Each port shows its own version.
Easy Say AWS and DevOps in two lines
Why: If you can say it simply, you understand it. Interviewers want the short version first.
What to do: Write two short lines about AWS and DevOps for a friend who is new to IT.
- Write what problem it solves.
- Write one command or file you used for it.
- Read it aloud.
Check: Your friend understands it without asking a question.
Easy Run the commands again from memory
Why: Typing from memory makes the commands stick. Copy-paste does not.
What to do: Close this page and run the main steps of this lesson again.
- Open a fresh terminal.
- Type each command yourself.
- Open the page only when stuck.
Check: You got the same green output without copying.
Medium Break it on purpose
Why: You must know the red message by face. In a real job there is no time to read slowly.
What to do: Cause one error from the "When it is red" part of this lesson and fix it.
- Follow one error section.
- Copy the exact message into your notes.
- Write the fix in one line.
Check: You fixed it using only your notes.
Medium Write a one-page note
Why: A short note in your own words is the best revision.
What to do: Write a note page for this lesson in ~/devops-lab/notes.md.
- Title, why, the commands, one error and its fix.
Check: A classmate can follow your note alone.
Hard Explain it like an interview
Why: Interviewers want real stories, not definitions.
What to do: Record a 60 second answer about this lesson on your phone.
- Say the problem, what you did, the command you ran, and one error you hit.
Check: Your answer has a real command and a real error message.
Hard Draw the flow top to bottom
Why: A drawing shows the order of things.
What to do: Draw this lesson as boxes from top to bottom on paper.
- One box per step.
- Write the command next to each box.
Check: Each box matches a step you really ran.
Easy Teach it to someone
Why: Teaching shows the gaps in your own understanding.
What to do: Explain this lesson to a friend or family member in five minutes.
- Use one real app as the example (Swiggy, Netflix, Paytm).
Check: They can tell you back the main idea.
Homework: try at home
Try at home
At home, run all three ways again on a fresh Ubuntu VM or an EC2 t3.micro. Write the time each way took and how many commands you typed. Then change the page text to v5 and see which way is fastest to repeat.
Recap
- AWS rents servers; DevOps is how you ship to them safely and often.
- A manual deploy is slow and error prone.
- A script makes the steps repeatable and self-checking.
- A container carries the app and its server together.
- Every later chapter builds on these three ideas.
FAQ
Do I need DevOps if I know AWS well?
Yes. AWS skills create servers. DevOps skills ship code to them every day without breaking things.
Is DevOps a job title or a culture?
Both. It started as a culture. Today many companies also hire "DevOps Engineers".
Should I learn Docker before Kubernetes?
Yes. Kubernetes runs containers, so you need to understand containers first.
Can I do this course on Windows?
Yes, use WSL2 with Ubuntu. Lesson 0.2 shows how.
Is Bash still needed when we have tools?
Yes. Every tool, from Jenkins to Kubernetes, runs shell commands underneath.
Interview questions
-
What is DevOps in one line?
A way of working where development and operations share ownership and automate building, testing and releasing software.
-
How is DevOps different from AWS?
AWS is a cloud provider. DevOps is a set of practices and tools that can use AWS, Azure or your own servers.
-
Why automate a deploy?
To make it fast, repeatable and less error prone, so teams can release many times a day.
-
Why are containers popular in DevOps?
They package the app with its dependencies, so it runs the same in every environment.
-
Give an example of a manual step you automated.
For example, a Bash script that installed nginx, copied the page, restarted it and checked the result with curl.
Quick quiz
Q1. What does AWS give you, and what does DevOps add?
AWS gives servers and services. DevOps adds a safe, repeatable way to ship changes to them.
Q2. Why is a manual deploy risky?
A human can skip or mistype a step, and each server can end up different.
Q3. What does set -euo pipefail do?
Stops the script at the first error.
Q4. Why do we pin nginx:1.27-alpine and not latest?
So the same image is used every time.
Q5. Which deploy is easiest to repeat on a new machine?
The Docker one, because the image carries the app and the server.
Did you understand? Let us try it once more.