Checking your sign-in…
This lesson is in Phase 2 — ₹799, one-time
Pay once with UPI, card or netbanking. Keep it forever. Your progress saves, so you can stop and come back.
← Back to all lessonsBreak-and-Fix Labs — Learn Like On-Call Work
Phase 2 · The Rest of DevOpsWhat this is and why it matters
These labs teach you fixing: each one breaks something on purpose, so you practise finding the cause.
Think of a driving test where the teacher quietly lets one tyre down. You learn to notice the wobble, find the flat tyre, and fix it — instead of only reading about flat tyres.
In real work, fixing is the job itself. A broken system stays broken until someone reads the symptom and finds the cause.
- A symptom is what you can see: an error message, a blank page, a container that stopped.
- A cause is the real reason behind it: a wrong name, a missing file, a missing door.
- On-call work means being the person who fixes things when they break, even outside normal hours. The order is always the same: symptom, logs, cause, fix.
- Logs are the lines of text a program prints while it runs.
Each lab follows the same order: break it, read the symptom, find the cause, fix it. Do not read the fix first.
Try to find the cause with the commands you know, then check the fix.
Test status
Syntax-checked only. The labs were NOT run end-to-end on a clean machine yet. Nothing in this lesson promises a step works on a real machine. Where a step is unverified, this lesson says so.
What you need first
- Docker running (from zero-cost-lab.md).
- Git installed (from zero-cost-lab.md Step 2).
- A GitHub account (from zero-cost-lab.md Step 7), for Lab 3 only. If you have never pushed to GitHub before, do Step 7 first — it makes the account, the sign-in token (part 7c), and the first push, in order. Then come back here.
- A working folder:
~/devops-practice. ~/devops-practiceis a learner-created folder. You made it in zero-cost-lab.md Step 6. It does NOT come with the kit.- Labs 4 and 6 make their own folders inside it (see each lab).
- Labs 1, 2, and 5 can run from any folder, because they only use Docker commands. Lab 3 needs a repository folder on GitHub (see Lab 3 setup).
- Clean up at the end of each lab. Stopped and running containers are left behind if you skip clean-up, and the next lab may fail with "port is already allocated" because door 8080 is still taken. Each lab below ends with its clean-up commands.
Words you will see in every lab
- Image — a saved, ready-to-run copy of an app.
- Tag — the version label after the colon in an image name, for example
1.0inmy-site:1.0. - Daemon — the background program that does Docker's work for you. When an error says "Error response from daemon", it means Docker's background program is the one reporting the problem.
- Port — a numbered door for network traffic.
- localhost — this machine. Your own computer.
- PATH — the list of folders the computer searches when you run a command by name. If a program is not in any of those folders, the computer says "executable file not found in $PATH".
- Foreground program — the main program a container runs. A container lives only as long as its main program runs. When the main program ends, the container stops.
Lab 1 — The container that will not start
What is this?
- A container that will not start because the image name is wrong.
- Think of ordering a pizza called "pizzza" from a shop that has no such pizza. The shop says "we do not have that". Docker does the same.
Break it
- WHAT we are doing: trying to start a container from an image that does not exist.
- WHY: so you see the exact error Docker gives for a wrong image name, and learn to read it.
docker run -d --name broken-web nginxg- Word by word:
docker run(start a container) +-d(run in the background) +--name broken-web(call itbroken-web) +nginxg(the image name —nginxgis a typing mistake on purpose. The real image is callednginx. There is no image callednginxg.) -dmeans detached: run in the background, so your terminal stays free.
Symptom
- Docker prints an error and no container runs.
- You should see an error like:
Unable to find image 'nginxg:latest' locally
docker: Error response from daemon: pull access denied for nginxg, repository does not exist or may require 'docker login'.- How to read it, line by line:
Unable to find image 'nginxg:latest' locally: Docker looked on your machine for an image callednginxg, versionlatest, and did not find it.latestis the default tag. When you write no tag, Docker reads it aslatest.Error response from daemon: Docker's background program is reporting the problem.pull access denied for nginxg: Docker tried to download (pull) the image from the internet and was refused.repository does not exist: a repository here means the named image on Docker Hub. Docker Hub is the public place where ready-made images live. There is no image callednginxgthere.or may require 'docker login': Docker adds this guess because the same error can also mean "this image is private, sign in first". Here the image simply does not exist. You do not need to sign in.
Find it
docker ps -a- WHAT: list all containers, including stopped ones.
- WHY: to prove no
broken-webcontainer was made. - Word by word:
docker ps(list running containers) +-a(all — include stopped ones too). - You should see: no
broken-webcontainer in the list. - The error message says the image could not be found. Docker could not download something that does not exist.
Fix it
docker run -d --name working-web nginx
docker ps- Line 1:
docker run -d --name working-web nginx. - WHAT: start a container from the real image
nginx, and call itworking-web. - WHY: the only mistake was the image name. The real name fixes it.
- Line 2:
docker ps. - WHAT: list running containers.
- WHY: to see
working-webrunning. - You should see:
working-webin the list with STATUS "Up". Upmeans running.- The container runs.
- Lesson: when a container will not start, read Docker's error and check the image name and tag first.
- Two extra checks you can use:
docker image ls(list the images on your machine —lsmeans list), or trydocker pull IMAGE:TAG(download one image by name and tag, to test whether it exists). - Use
docker logsonly when a container actually exists and printed output. For an image that was never pulled, there is no container to read logs from.docker logsmeans "show what this container printed".
Second version (try this yourself)
- First, check what is using door 8080. Run
docker psand look at the PORTS column. Ifworking-webis running without a-pdoor mapping, it uses no door on your machine, so this second version will NOT clash. The clash below only happens if another container already uses door 8080 — for example themy-sitecontainer from zero-cost-lab.md Step 4, if it is still running.
docker run -d --name second-web -p 8080:80 nginx- Word by word:
docker run(start a container) +-d(background) +--name second-web(call itsecond-web) +-p 8080:80(connect door 8080 on your machine to door 80 in the container) +nginx(the web server program). - You should see an error like (only if door 8080 is already taken):
Bind for 0.0.0.0:8080 failed: port is already allocated- How to read it:
Bind ... failedmeans "I could not take door 8080".port is already allocatedmeans "door 8080 is already in use by something else".0.0.0.0means "all addresses on this machine". - If your first web container is still using port 8080, this one fails. Fix: stop the first one (
docker stop working-web— but note: ifworking-webhas no-pmapping, it is not the one using the door; stop the container that does use 8080, which you found indocker ps), or use a different port (-p 8081:80— same box, door 8081 on your machine instead of 8080).
Clean up Lab 1
docker stop working-web second-web
docker rm working-web second-web- WHAT: stop both containers, then delete them.
- WHY: so door 8080 is free for the next lab.
- Word by word:
docker stop(stop) + the two names.docker rm(remove, delete) + the two names. Ifsecond-webwas never made (because it failed), thestopline will say "no such container" for it. That is fine. Remove the one that exists.
Lab 2 — The container that starts, then dies
What is this?
- A container that starts, then stops at once, because the command inside it does not exist.
- Think of a music player told to play a song that is not on the playlist. It has nothing to play, so it stops.
Break it
docker run --name dying-app ubuntu badcommand- Word by word:
docker run(start a container) +--name dying-app(call itdying-app) +ubuntu(the image: Ubuntu, a version of Linux, as a ready-made box) +badcommand(the command to run inside the box —badcommanddoes not exist. That is the mistake, on purpose.) - Note: there is no
-dhere. Without-d, the container runs in your terminal, in the foreground, and you see its error directly.
Symptom
- The container appears, then stops at once.
- You should see an error like:
exec: "badcommand": executable file not found in $PATH- How to read it:
execmeans "run this program"."badcommand"is the program name.executable file not found in $PATHmeans "there is no program calledbadcommandin any folder the computer searches". An executable file is a file the computer can run as a program.$PATHis the list of folders the computer searches.
Find it
docker ps -a
docker logs dying-app- Line 1:
docker ps -a. - WHAT: list all containers, including stopped ones.
- WHY: a dead container disappears from plain
docker ps, but still shows indocker ps -a. - Line 2:
docker logs dying-app. - WHAT: show what the container printed before it stopped.
- WHY: the printed lines name the problem.
- You should see:
dying-appin the list with STATUS "Exited", and the log shows the error above.Exitedmeans stopped. - The command does not exist, so the container had nothing to do and exited. A container lives only as long as its main program runs.
Fix it
docker rm dying-app
docker run -d --name living-app ubuntu sleep 1000
docker ps- Line 1:
docker rm dying-app. - WHAT: delete the dead container.
- WHY: the name
dying-appis taken until you delete it. Also, a dead container only clutters the list. - Line 2:
docker run -d --name living-app ubuntu sleep 1000. - WHAT: start a new container from the
ubuntuimage, running the commandsleep 1000, in the background, calledliving-app. - WHY:
sleep 1000is a program that simply waits for 1000 seconds, doing nothing. 1000 means 1000 seconds, which is about 16 minutes. While it waits, the container stays alive, so you can see STATUS "Up". - Word by word:
docker run+-d(background) +--name living-app(call itliving-app) +ubuntu(the image) +sleep 1000(the command: wait 1000 seconds). - Line 3:
docker ps. - WHAT: list running containers.
- WHY: to see
living-appwith STATUS "Up". - You should see:
living-appin the list with STATUS "Up". - If it breaks: if
living-appexits at once too, check the command spelling.sleep 1000must be typed exactly. sleep 1000is a process-lifetime demonstration only, not a real fix. Never hide a broken app behind a waiting command.- Process-lifetime means "how long the main program runs".
- The real-app version: run a program that is meant to stay in the foreground, for example
docker run -d --name living-web nginx. nginx itself is the foreground program, so the container stays alive doing real work. A container stops when its main program exits. - The foreground program is the main program. Foreground means "the one in front, doing the work".
Clean up Lab 2
docker stop living-app
docker rm living-app- WHAT: stop the waiting container, then delete it.
- WHY:
sleep 1000ends after about 16 minutes anyway, but stopping it now keeps your machine tidy and frees the name.
Lab 3 — The pipeline that fails
What is this?
- A pipeline is an automatic chain of steps, like a factory line.
- GitHub Actions is GitHub's built-in pipeline tool. It runs steps for you every time you push code to GitHub.
- Pushing means sending your saved work from your machine to GitHub.
- This lab breaks a pipeline on purpose: the pipeline is told to run a file that does not exist.
- Think of a recipe that says "open the blue tin" when there is no blue tin in the cupboard. The cook stops and says "tin not found". The pipeline does the same.
The setup
- WHAT we are doing: making a folder with a GitHub Actions workflow file in it, and putting that folder on GitHub.
- WHY: the pipeline only runs on GitHub. It cannot run on your machine alone. You need a repository on GitHub first.
- A workflow file is a settings file that describes the pipeline steps.
- A repository is a folder on GitHub that holds your project. People usually say "repo" for short.
- Do this setup in
~/devops-practice(learner-created, from zero-cost-lab.md Step 6), in a folder for this lab, for example~/devops-practice/pipeline-lab. Make it first:
mkdir -p ~/devops-practice/pipeline-lab
cd ~/devops-practice/pipeline-lab- WHAT: make a folder called
pipeline-labinside~/devops-practice, and move into it. - WHY: all the files for this lab live in one place.
- Word by word:
mkdir -p(make a folder, making missing parents too) + the folder path.cd(move into the folder) + the folder path. - Then make the repository on GitHub, exactly as in zero-cost-lab.md Step 7: make a free account, click "New repository", name it, leave it empty (do NOT tick "Add a README file"), create it, and copy the repository address. It looks like
https://github.com/<you>/<repo>.git. - Then connect this folder to it and push, exactly as in zero-cost-lab.md Step 7 (
git init,git add .,git commit -m "first commit",git branch -M main,git remote add origin <your repository address>,git push -u origin main). When the push asks for a password, paste the token from zero-cost-lab.md Step 7, part 7c — never your GitHub password. GitHub does not accept your normal password for pushes any more; only the token works. If you have not done Step 7 yet, do it now, in order: 7a makes the repository, 7b starts tracking the folder and sets your name and email, 7c makes the token, 7d is the first push. This lab needs all four done before the workflow file below can run.
The workflow file
- The file lives at
.github/workflows/check.ymlin the repository. - That path means: inside your repository folder, a folder called
.github, inside it a folder calledworkflows, inside it a file calledcheck.yml. .githubstarts with a dot. A name that starts with a dot is a hidden folder. Hidden means your file manager does not show it by default, but it is really there. In the terminal,ls -ashows hidden files.lsalone hides them.workflowsis GitHub's name for the folder that holds pipeline files.check.ymlis the file name..ymlmeans it is a YAML settings file.- Make the folders and the file. From inside
~/devops-practice/pipeline-lab, run:
mkdir -p .github/workflows
cat > .github/workflows/check.yml << 'EOF'
name: check
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run the tests
run: ./run-tests.sh
EOF- Line 1:
mkdir -p .github/workflows. - WHAT: make the hidden folder
.githuband the folderworkflowsinside it. - WHY: the workflow file must live at exactly this path, or GitHub will not find it.
- Lines 2 to 11:
cat > .github/workflows/check.yml << 'EOF'…EOF. - WHAT: write the lines between the markers into the file
.github/workflows/check.yml. - WHY: this creates the workflow file.
cat >writes the lines that follow into a file until it sees the lineEOF.EOFmeans "end of file". It is just a marker word.- Inside the file, line by line:
name: check— WHAT: call this pipelinecheck. WHY: so you can find it by name on GitHub.on: [push]— WHAT: run this pipeline every time someone pushes code. WHY: a push is the trigger.[push]means "on a push".jobs:— WHAT: the list of jobs in this pipeline. WHY: a job is a set of steps that runs on one machine. This pipeline has one job.build:— WHAT: call the jobbuild. WHY: so you can refer to it by name.runs-on: ubuntu-latest— WHAT: run this job on GitHub's newest Ubuntu machine. WHY: the steps need a machine to run on, and GitHub provides one. Ubuntu is a version of Linux.steps:— WHAT: the list of steps in this job. WHY: the steps run one after another.- uses: actions/checkout@v4— WHAT: use GitHub's ready-made step calledcheckout, version 4. WHY: it downloads your repository files onto the machine, so the later steps can use them. The-starts one item in the list.actions/checkout@v4means "the checkout step, version 4, made by GitHub".- name: Run the tests— WHAT: call the next step "Run the tests". WHY: so you can see which step failed, by name, in the log.run: ./run-tests.sh— WHAT: run the file calledrun-tests.shin the repository folder. WHY: that file holds the tests../means "in this folder".run-tests.shis the file name..shmeans it is a shell script file.- YAML uses spaces for structure. Never use the Tab key in a
.ymlfile. If a YAML file fails with a strange error, check the spaces first. - Push this file to GitHub (
git add .,git commit -m "add pipeline",git push). Those three lines are the same short push from zero-cost-lab.md Step 7: stage, save, send.
Break it
- Do not create
run-tests.shin the repository. Push the code. - That is the whole break: the pipeline is told to run a file that does not exist.
run-tests.shmust live in the repository folder (~/devops-practice/pipeline-lab), at the top level, next to the.githubfolder — not inside.github, and not in another folder. That is where./run-tests.shlooks for it.
Symptom
- The pipeline runs and fails at the "Run the tests" step.
- How to see it: on GitHub, open your repository, click the "Actions" tab at the top. The Actions tab lists every pipeline run. The newest run is at the top. A failed run shows a red X. A passing run shows a green tick. Click the failed run, then click the job called
build, then click the step called "Run the tests". Its log is the list of lines that step printed. - The log says the file was not found. The pipeline did exactly what it was told. It tried to run a file that does not exist.
- How long to wait: a run usually starts within a minute of the push and finishes in under two minutes. If the Actions tab shows no run after two minutes, check that the push really went through (
git pushprinted no error) and that the file is at.github/workflows/check.ymlexactly.
Find it
- Open the failed run on GitHub and read its log.
- The log says the file was not found.
- The pipeline did exactly what it was told. It tried to run a file that does not exist.
Fix it
- Write a real
run-tests.shfile — one that checks something true about the project — and push it. - For a static site, this is enough to start. A static site is a website made of plain files, with no program running behind it.
- First, you need an
index.htmlin the repository folder, because the tests below check it. If you do not have one yet, make it:
cat > index.html << 'EOF'
<h1>My DevOps practice site</h1>
EOF- WHAT: write a tiny web page file called
index.htmlwith one heading. - WHY: the tests below check this file, so it must exist first.
- Then make the test file, in the same folder (
~/devops-practice/pipeline-lab):
#!/bin/bash
test -f index.html
grep -q "My DevOps practice site" index.html- HOW to write it:
cat > run-tests.sh << 'EOF', then the three lines above, thenEOFon its own line. - Inside the file, line by line:
#!/bin/bash— WHAT: the first line says "run this file with Bash". WHY: Bash is the command language. Without this line, the computer would not know which language the file is written in. Type it exactly as shown.test -f index.html— WHAT: check that a file calledindex.htmlexists. WHY: if the file is missing, the test fails, and you want to know that. Word by word:test(check something) +-f(a file exists) +index.html(the file name).grep -q "My DevOps practice site" index.html— WHAT: check that the fileindex.htmlholds the words "My DevOps practice site". WHY: if someone deletes the heading, the test fails, and you want to know that. Word by word:grep(search inside a file) +-q(quiet — print nothing, only say yes or no by passing or failing) +"My DevOps practice site"(the words to look for) +index.html(the file to search in).- Make it runnable, then push again, and watch the pipeline go green:
chmod +x run-tests.sh
git add .
git commit -m "add tests"
git push- Line 1:
chmod +x run-tests.sh. - WHAT: mark the file as runnable.
- WHY: a new text file is not runnable yet. The pipeline would say "permission denied" if you skip this. This is the same
chmod +xyou met in zero-cost-lab.md Step 8. On GitHub, the pipeline runs the file, so the file must be runnable there too — and Git remembers the runnable mark when you push. - Word by word:
chmod(change the file's permissions) ++x(add the "can run" permission) +run-tests.sh(the file). - Lines 2 to 4:
git add .,git commit -m "add tests",git push. - WHAT: stage, save with the message "add tests", and send to GitHub.
- WHY: the pipeline only runs on what is on GitHub. Until you push, GitHub cannot see the new files.
- You should see: the pipeline run turns green on the Actions tab.
- Green means passed. Go to the Actions tab, find the newest run, and look for a green tick. Click it to see the "Run the tests" step with a green tick too.
- If it breaks: if it is still red, open the failed run, read the failed step's log, and find the first error line. That is the one thing to fix first.
- Then break it on purpose once: delete the heading from
index.html, watch the test step fail, restore it, and watch it pass. - HOW to delete the heading: open
index.html, delete the line with "My DevOps practice site", save, push. The pipeline will fail. - HOW to restore it: put the line back, save, push. The pipeline will pass again.
- WHY this matters: it proves the test really checks something.
- Never replace a missing test with a command that only prints "tests passed". A green pipeline that checked nothing is worse than a red one.
- WHAT that means: a line like
echo "tests passed"always passes, even when everything is broken. It lies. A real test checks a real file.
Lesson
- Most pipeline failures are not mysterious. Read the failed step's log, find the first error line, and fix that one thing first.
Clean up Lab 3
- There is nothing to stop or delete on your machine: the pipeline runs on GitHub, not in a container here.
Lab 4 — The Git merge conflict
What is this?
- A merge conflict is when two people (or two lines of work) changed the same lines, and Git stops and asks you to choose.
- Think of two people editing the same sentence in a shared document. One writes "the cat sat". The other writes "the dog sat". The document cannot hold both. Someone must pick one.
- Git shows you both versions side by side. You pick, you delete the marker lines, and you save. That is all a conflict is.
The setup
- WHAT we are doing: making a small folder with a small Git history, so we can create a conflict on purpose.
- WHY: you cannot practise fixing a conflict without one. This setup makes one.
- Git needs to know who you are before your first commit, so set that once. These settings are for this folder only, not for your whole machine. That is why there is no
--globalhere.--globalwould mean "for all projects on this machine".
mkdir -p ~/devops-practice/git-conflict
cd ~/devops-practice/git-conflict
git init
git branch -M main
git config user.name "Learner"
git config user.email "learner@example.com"- Line 1:
mkdir -p ~/devops-practice/git-conflict. - WHAT: make a folder called
git-conflictinside~/devops-practice. - WHY: this lab lives in its own folder, so it does not mix with other work.
- Line 2:
cd ~/devops-practice/git-conflict. - WHAT: move into that folder.
- WHY: every Git command after this runs inside it.
- Line 3:
git init. - WHAT: start tracking this folder with Git.
- WHY: until you do this, Git does not watch the folder at all.
- Line 4:
git branch -M main. - WHAT: name your main line of work "main".
- WHY: so the main line has the usual name from the start.
- Word by word:
git branch(work with lines of work) +-M(rename) +main(the name). - Line 5:
git config user.name "Learner". - WHAT: save the name "Learner" for this folder's Git work.
- WHY: every save (commit) is stamped with a name. Git refuses to save without one.
- Use your own name if you like. "Learner" is just the example.
- Line 6:
git config user.email "learner@example.com". - WHAT: save the email
learner@example.comfor this folder's work. - WHY: every save is stamped with an email too.
learner@example.comis a fake example email, for practice only. It is not a real address. Do not use it for real work. For real work, use your own email, as in zero-cost-lab.md Step 7.- You should see:
Initialized empty Git repository in /home/learner/devops-practice/git-conflict/.git/- How to read it:
Initialized empty Git repository in ...means Git started tracking this folder. The path ends in.git/..gitis Git's hidden folder inside your folder, where it keeps the history. Your home folder name will be different from/home/learner. That is fine. - The
configlines print nothing when they work. That is normal. - If it breaks: "No such file or directory" means the folder was not made. Run the
mkdirline again first.
Make a first version and save it
cat > notes.txt << 'EOF'
Line one
EOF
git add notes.txt
git commit -m "first version"- Lines 1 to 3:
cat > notes.txt << 'EOF'…EOF. - WHAT: write the line
Line oneinto a file callednotes.txt. - WHY: this is the file the two lines of work will both change.
cat >writes the lines that follow into a file until it sees the lineEOF.EOFmeans "end of file".- Line 4:
git add notes.txt. - WHAT: stage the file
notes.txt. - WHY: staging marks it to be saved in the next commit.
- Line 5:
git commit -m "first version". - WHAT: save the staged file, with the message "first version".
- WHY: a commit is a saved snapshot. The message says what changed.
- You should see a commit line like:
[main (root-commit) abc1234] first version- How to read it:
[main ...]means the save is on themainline.root-commitmeans the first save in this folder.abc1234is the short code for this save. Yours will be different.first versionis your message.
Make a branch and change the same line there
git checkout -b feature
cat > notes.txt << 'EOF'
Line one, edited on feature
EOF
git add notes.txt
git commit -m "feature edit"- Line 1:
git checkout -b feature. - WHAT: make a new branch called
featureand move onto it. - WHY: a branch is a separate line of work, so you can try changes without touching the main line.
- Word by word:
git checkout(move to a line of work) +-b(make a new one first) +feature(the name). - Lines 2 to 4:
cat > notes.txt << 'EOF'…EOF. - WHAT: replace the file with the line
Line one, edited on feature. - WHY: this is the feature branch's version of the same line.
- Line 5:
git add notes.txt. - WHAT: stage the file.
- Line 6:
git commit -m "feature edit". - WHAT: save it, with the message "feature edit".
- You should see:
Switched to a new branch 'feature'
[feature abc1234] feature edit- How to read it:
Switched to a new branch 'feature'means you are now on thefeatureline.[feature abc1234] feature editis the save, onfeature, with your message. Your commit code will be different.
Go back to the main line and change the same line differently
git checkout main
cat > notes.txt << 'EOF'
Line one, edited on main
EOF
git add notes.txt
git commit -m "main edit"- Line 1:
git checkout main. - WHAT: move back to the
mainline. - WHY: so you can make a different change to the same line there.
- Word by word:
git checkout(move to a line of work) +main(the line's name). There is no-bthis time, becausemainalready exists. - Lines 2 to 4:
cat > notes.txt << 'EOF'…EOF. - WHAT: replace the file with the line
Line one, edited on main. - WHY: this is the main line's version of the same line.
- Line 5:
git add notes.txt. Line 6:git commit -m "main edit". - WHAT: stage and save, with the message "main edit".
- You should see:
Switched to branch 'main'
[main abc1234] main edit- How to read it: you are back on
main, and the save is onmain.
Break it
- Try to merge the branch in:
git merge feature- WHAT: merge the
featureline into the line you are on (main). - WHY: merging is how a finished branch joins the main line.
- Word by word:
git merge(join lines of work) +feature(the line to join in).
Symptom
- Git stops and says there is a CONFLICT in
notes.txt. - Nothing is merged yet.
- This is normal. Git is asking you to choose, not telling you something broke badly.
Find it
cat notes.txt- WHAT: print the file
notes.txt. - WHY: to see the two versions and the marker lines Git added.
- You should see markers like this:
<<<<<<< HEAD
Line one, edited on main
=======
Line one, edited on feature
>>>>>>> feature- How to read it, line by line:
<<<<<<< HEAD— WHAT: the start of your current line's version. WHY: Git marks where it begins.HEADmeans "the line you are on right now", which ismain. The<marks are just markers. They are not part of your file's real text.Line one, edited on main— WHAT: themainversion of the line.=======— WHAT: the divider between the two versions. WHY: it separates "yours" (above) from "theirs" (below).Line one, edited on feature— WHAT: thefeatureversion of the line.>>>>>>> feature— WHAT: the end of the incoming version, and the name of the line it came from (feature). WHY: Git marks where it ends.
Fix it
- Edit
notes.txtso it holds the one version you want, and delete all three marker lines. - HOW: open
notes.txtinnano(typenano notes.txt, change the text, press Ctrl+O then Enter to save, Ctrl+X to leave). - For example, keep:
Line one, edited on main- That means the file holds exactly one line, and none of the three marker lines (
<<<<<<< HEAD,=======,>>>>>>> feature) remain. - Never commit a file with marker lines still in it. They are not real text. They would stay in your file forever.
- Then finish the merge:
git add notes.txt
git commit- Line 1:
git add notes.txt. - WHAT: stage the fixed file.
- WHY: staging tells Git "this conflict is resolved, use this version".
- Line 2:
git commit. - WHAT: save the merge, with no message of your own.
- WHY: Git already wrote a merge message for you, like "Merge branch 'feature'". It opens your editor so you can read it.
- Which editor opens: Git opens the editor it is set to use. On a fresh machine this is usually
nanoorvim. Ifnanoopens, press Ctrl+O then Enter to save, Ctrl+X to leave. Ifvimopens, press Esc, then type:wqand press Enter.:wqmeans "write (save) and quit". If you do not know which editor you are in, look at the bottom of the screen:nanoshows its shortcuts at the bottom;vimshows nothing there and shows-- INSERT --at the bottom when you are typing. - To avoid the editor entirely, you can run
git commit --no-editinstead.--no-editmeans "use Git's message as it is, do not open the editor". - You should see: your editor opens with the merge message. Save and close it, and the merge is done.
- If it breaks: "nothing to commit" means the markers are still in the file, or you forgot
git add. Opennotes.txt, remove all three marker lines, then rungit add notes.txtandgit commitagain. - The merge is done.
- Lesson: a conflict is Git showing you both versions side by side. Read the markers, pick the right lines, remove the markers, and commit.
Clean up Lab 4
- There is nothing to stop or delete on your machine: no container runs in this lab.
Lab 5 — The app runs, but the browser shows nothing
What is this?
- The app works, but your browser cannot reach it, because no door was opened into the container.
- Think of a shop that is open, but its front door is bricked up. The shop is fine. You just cannot get in.
Break it
docker run -d --name quiet-web nginx- WHAT: start the nginx web server in a container called
quiet-web, in the background. - WHY: this is the break. There is no
-pdoor mapping this time. That missing mapping is the mistake, on purpose. - Word by word:
docker run(start a container) +-d(background) +--name quiet-web(call itquiet-web) +nginx(the web server). - You should see: a long container ID printed, then your prompt back. A container ID is a code for this container. You do not need it.
- No port mapping this time. That is the mistake, on purpose.
Symptom
docker psshowsquiet-webrunning.- But opening
http://localhost:8080in your browser says the site cannot be reached. localhostmeans "this machine".8080is the door number.- The app is fine. The door to it is missing.
Find it
docker ps
docker logs quiet-web- Line 1:
docker ps. - WHAT: list running containers.
- WHY: to see
quiet-webrunning, and to look at its PORTS column. - Line 2:
docker logs quiet-web. - WHAT: show what the container printed.
- WHY: to check the app itself started normally.
- You should see:
quiet-webrunning, but the PORTS column is empty.docker logsshows nginx started normally. - How to read that: the PORTS column is where the door mapping would show, like
0.0.0.0:8080->80/tcp. Empty means no door was opened. The logs prove the app started. They do not prove a port is published. The PORTS column indocker psis the evidence for that. - So the container works. Your machine simply has no door into it. A container's own port 80 does not reach your browser by itself. The
-pmapping is what connects the two.
Fix it
docker stop quiet-web
docker rm quiet-web
docker run -d -p 8080:80 --name quiet-web nginx- Line 1:
docker stop quiet-web. - WHAT: stop the container called
quiet-web. - WHY: you cannot add a door to a running container. You must make a new one with the door included.
- Line 2:
docker rm quiet-web. - WHAT: delete the stopped container.
- WHY: the name
quiet-webis taken until you delete it. The new container needs the same name. - Line 3:
docker run -d -p 8080:80 --name quiet-web nginx. - WHAT: start a new container, same name, same image, but this time with door 8080 on your machine connected to door 80 in the container.
- WHY: the
-p 8080:80mapping is the door. Without it, the browser cannot reach the app. With it, it can. - You should see: the welcome page at
http://localhost:8080. - Open
http://localhost:8080again. The welcome page appears. The welcome page says "Welcome to nginx!". If you see it, the door works.
Second version (try this yourself)
- Stop the first container, then run one with a different host port:
docker stop quiet-web
docker run -d -p 8081:80 --name second-quiet nginx- Line 1:
docker stop quiet-web. - WHAT: stop the container called
quiet-web. - WHY: so door 8080 is free, and so you can see the difference between the two doors.
- Line 2:
docker run -d -p 8081:80 --name second-quiet nginx. - WHAT: start a new container called
second-quiet, with door 8081 on your machine connected to door 80 in the container. - WHY: to prove the first number in
-pis your machine's door. - You should see:
http://localhost:8080shows nothing. Nothing answers there any more, becausequiet-webis stopped and nothing uses door 8080 now. Openhttp://localhost:8081and it works. - Lesson: the first number in
-pis your machine's door; the second is the container's. Check which door you actually opened.
Clean up Lab 5
docker stop second-quiet
docker rm second-quiet- WHAT: stop the second container, then delete it.
- WHY: so door 8081 is free and no container is left running.
Lab 6 — The build fails: file not found
What is this?
- A build fails because the Dockerfile asks for a file that does not exist.
- Think of a recipe that says "add the flour from the blue tin" when the blue tin is empty. The cook stops. The build stops the same way.
The setup
- WHAT we are doing: making a folder with a web page file and a Dockerfile that copies a file which does not exist there.
- WHY: so the build fails in the exact way this lab teaches you to fix.
- A Dockerfile is a short recipe file. It says how to build an image.
- The build context is the folder you build from. The build can only see files in that folder. Files outside it are invisible to the build.
mkdir -p ~/devops-practice/build-fail
cd ~/devops-practice/build-fail
cat > index.html << 'EOF'
<h1>My site</h1>
EOF
cat > Dockerfile << 'EOF'
FROM nginx:1.27-alpine
COPY app.html /usr/share/nginx/html/app.html
EOF- Line 1:
mkdir -p ~/devops-practice/build-fail. - WHAT: make a folder called
build-failinside~/devops-practice. - WHY: this lab lives in its own folder.
- Line 2:
cd ~/devops-practice/build-fail. - WHAT: move into that folder.
- WHY: every command after this runs inside it, and the build in the next step uses this folder as its build context.
- Lines 3 to 5:
cat > index.html << 'EOF'…EOF. - WHAT: write a tiny web page file called
index.html. - WHY: this is the file that DOES exist. The Dockerfile below asks for a different file, which does not exist.
- Lines 6 to 9:
cat > Dockerfile << 'EOF'…EOF. - WHAT: write a file called
Dockerfilewith two lines. - WHY: this is the recipe the build will follow, and it holds the mistake.
- Inside the file, line by line:
FROM nginx:1.27-alpine— WHAT: start from thenginximage, version1.27-alpine. WHY: every Dockerfile starts with aFROMline that names the base image. The base image is the ready-made starting point. The tag pins the version — the kit never useslatest, which moves.COPY app.html /usr/share/nginx/html/app.html— WHAT: copy a file calledapp.htmlfrom this folder into the image, to the path/usr/share/nginx/html/app.html. WHY: that path is where nginx looks for web pages inside the image. The first part (app.html) is the file in your folder. The second part is where it goes inside the image. The mistake is thatapp.htmldoes not exist in your folder. Onlyindex.htmldoes.- You should see: nothing. These commands print nothing when they work. That is normal.
Break it
docker build -t fail-demo:1.0 .- WHAT: build an image called
fail-demo:1.0from the files in this folder. - WHY: the build will fail at the COPY step, because
app.htmlis missing. - Word by word:
docker build(build an image) +-t(give it this name) +fail-demo:1.0(the name and version —fail-demois the name,1.0is the tag) +.(this folder — the dot means "build from the files right here". This folder is the build context.) - You should see an error like:
COPY failed: file not found in build context- How to read it:
COPY failedmeans the COPY step failed.file not found in build contextmeans the file was not found in the folder you are building from. The build context is the folder you build from.
Symptom
- The build stops at the COPY step with an error like "file not found".
- The folder holds
index.html, but the Dockerfile asks forapp.html, which is not there.
Find it
- Read the failed step in the build output: it names the missing file.
- Then check what is actually in the folder:
ls- WHAT: list the files in this folder.
- WHY: to see with your own eyes which files really exist.
- Word by word:
ls(list files). - You should see:
index.htmllisted, but noapp.html. - The build can only see files in the folder you build from. The dot in
docker build -t fail-demo:1.0 .means "this folder". That folder is called the build context, and files outside it are invisible to the build. - If a file that IS in the folder is still missing from the build, check
.dockerignore. It can exclude files from the context. - WHAT
.dockerignoreis: a file that lists files the build must ignore, even though they sit in the folder. Its name starts with a dot, so it is a hidden file. - WHY it matters: if
app.htmlwere listed in.dockerignore, the build would say "file not found" even though you can see the file in the folder. Check it withcat .dockerignore(print the file). If the missing file is listed there, remove that line.
Fix it
- Either create the missing file, or fix the Dockerfile to copy the file that exists. The honest fix here is the second one: the file that exists is
index.html, so the Dockerfile should copy that.
cat > Dockerfile << 'EOF'
FROM nginx:1.27-alpine
COPY index.html /usr/share/nginx/html/index.html
EOF
docker build -t fail-demo:1.0 .- Lines 1 to 4:
cat > Dockerfile << 'EOF'…EOF. - WHAT: replace the Dockerfile with a fixed version.
- WHY: the fixed version copies
index.html, the file that exists, to/usr/share/nginx/html/index.html, where nginx looks for it. cat >writes the lines that follow into the file untilEOF, replacing what was there before.- Line 5:
docker build -t fail-demo:1.0 .. - WHAT: build the image again, from this folder.
- WHY: to prove the fix works.
- You should see: the build finish with no error, and the last line names
fail-demo:1.0. - If it breaks: if it still says "file not found", check you are in the
build-failfolder. Runpwdandlsfirst. - WHAT
pwdis: print the folder you are in right now. - WHY: if you are in the wrong folder, the build looks in the wrong place.
pwdtells you where you are.lstells you what is there. - The build passes.
- Lesson: when a build says a file is not found, check two things: does the file exist, and is it inside the folder you are building from?
Clean up Lab 6
docker rmi fail-demo:1.0- WHAT: delete the image called
fail-demo:1.0. - WHY: it was only a practice image. Deleting it keeps your machine tidy.
- Word by word:
docker rmi(remove an image) +fail-demo:1.0(the image name and tag).rmimeans "remove image".
After all six labs
- You can now say, truthfully: "I can read container logs, fix a port clash, fix a bad image name, resolve a merge conflict, find a missing port mapping, fix a failed build, and read a failed pipeline log."
- That sentence is worth more than a certificate with no practice.
- A certificate is a piece of paper. The sentence above is proof you did the work.
Keep practising with the data tier (Phase 1)
- The same break-and-fix habit applies to databases and queues.
- Phase 1 has its own practice built in: the PostgreSQL lab makes you kill the main database and promote the standby by hand, the load balancer lab makes you kill a backend and watch the site stay up, and the end-to-end lab puts it all together. Do those after these six labs.
- Promote the standby means: make the waiting copy the main one.
- A backend is one of the copies of your app behind the load balancer.
- End-to-end means from the first step to the last step, all together.
Sources (1–3)
- Pro Git book (free online) — https://git-scm.com/book — the full story on Git, including branching and conflicts, written clearly.
- Docker's official getting-started guide — https://docs.docker.com/get-started — the toolmaker's own first steps for Docker, in order.
- Learn Git Branching (browser game) — https://learngitbranching.js.org — practise Git branching in your browser, with no setup.
Advanced — Severity, incident timeline, rollback, alerting, and production logs
This section is for the reader who already did the six labs above. It covers the four things the review of this kit flagged as missing for advanced readers: severity, incident timeline, rollback, and alerting — plus production log tools — and it extends the fake-green-test lesson from Lab 3, which the review calls genuinely good. The commands were checked against this kit's own files and the tools' docs.
Advanced 1 — Severity: how bad is it, in one minute
What this is: severity is a grade for how bad an incident is, decided in the first minutes by who is hurt and how badly. Why it matters: the grade decides who gets woken up and whether you roll back first or investigate first. The full table, with examples, lives in the error decoder's Advanced section — the same four grades (S1 to S4) are used here, so learn them once.
The one rule to carry from this lab: Lab 1's container that will not start is an S1 if it is the live site and an S4 if it is your practice container. The error is the same. The severity is different. Severity is about users, not about errors. That is why the first question in an incident is never "what is the error?" but "who is hurt?"
Advanced 2 — Incident timeline: what to write down, in what order
What this is: an incident timeline is a written record of a production breakage, made while it is happening. Why it matters: memory lies, and the review after the incident is built from this record. The full seven-step list — start time, what users see, severity, checks, changes, recovery time, what is still unknown — lives in the error decoder's Advanced section. This section adds the habit that makes it real: practise it on these very labs.
Do it once, on paper, during Lab 2 (the container that starts, then dies). Write the start time, the symptom in one line, the severity (S4 — it is your practice container), each check and what it showed, each change and the time, and the recovery time. It feels slow the first time. The second time it is fast. In a real incident it is the difference between a team that knows what was tried and a team that tries the same failed fix three times. The timeline is also the proof you show in an interview when you say "I have handled incidents" — a story with times and checks beats a claim every time.
Advanced 3 — Rollback: the fastest fix is undoing the last change
What this is: a rollback is undoing the last change to restore the working version. Why it matters: when users are hurt, restoring service beats finding the root cause in the same hour. Understand second, roll back first.
The three rollbacks this kit already teaches, in one place:
- Git:
git revert <commit>makes a new commit that undoes the old one. That is the safe rollback on a shared branch, because it adds history instead of rewriting it. Never usegit reset --hardon a branch others already have — it rewrites history they already pulled, and their next pull will fight yours. (The merge-conflict lab already teaches the difference between rewriting and adding.) - Kubernetes:
kubectl rollout undo deployment/my-sitemoves a Deployment back to its previous version, andkubectl rollout history deployment/my-sitelists the versions you can go back to. This is the rollback for the Kubernetes lab'smy-siteDeployment. - Docker: re-run the previous image tag. That is why tags matter:
my-site:1.0is a version you can go back to, andmy-site:latestis not —latestmoves, so "the previous version" has no name. (See the portfolio lesson's Advanced section on pinning images.)
The rule, in one line: if a deploy just went out and everything broke, the newest change is the most likely cause, and rolling it back is the first move — not the last resort.
Advanced 4 — Alerting: a rule, a person, and a first step
What this is: an alert is a rule ("this number is wrong") plus a person who gets told, plus a first step they take. Why it matters: monitoring without alerting is a dashboard nobody watches. The numbers this kit already teaches, turned into alerts:
- Prometheus: the
upquery from the portfolio lesson. The alert rule isup == 0for 5 minutes — a target that stopped answering and stayed down. In Prometheus alert files the shape is: a group, a name, the expression (expr: up == 0), andfor: 5m(it must stay wrong for 5 minutes before it fires, so a 10-second blip does not wake anyone). - Kafka: consumer lag growing steadily for 10 minutes (see the Kafka lab's Advanced section). The number comes from
kafka-consumer-groups.sh --describe, per group, per partition. - The error rate: the share of requests answering with 500 errors. A jump in 500s after a deploy means roll back (Advanced 3).
Two rules that save teams. First: an alert must name its first step — "check the error decoder's 502 entry" or "roll back the Deployment" — or the person woken up wastes the first ten minutes deciding what to do. The runbook link is part of the alert. Second: alert fatigue — an alert that fires and nobody acts on is worse than no alert, because the team learns to ignore all of them. An alert nobody acted on three times gets tuned or deleted, not kept.
Advanced 5 — Production log tools: beyond docker logs
What this is: the step past docker logs and kubectl logs. Why it matters: in production, logs live on many machines, and the error you need is on a machine you are not looking at. Centralised logs — every service sending its logs to one place you can search — are what makes the error-decoder rule ("fix the FIRST error first") possible at scale.
The tools to know by name: journalctl (reads the machine's own system logs — journalctl -u docker shows Docker's own log on a Linux machine), and the central tools teams use: Splunk, Datadog, CloudWatch Logs, and Grafana Loki. This kit runs none of them; know their names and the idea. Two habits transfer from these labs to any of them: read the FIRST error in the chain (the error decoder's rule), and follow one request across services with a correlation ID — a code stamped on a request when it enters the system, carried through every service it touches, so you can pull all of its log lines with one search instead of guessing which lines belong together.
Advanced 6 — Extending the fake-green-test lesson (Lab 3)
Lab 3's lesson is genuinely good, and it is the ceiling of this kit's CI/CD teaching. Keep it, and extend it with four rules:
- A test must fail when the thing it guards breaks. Lab 3 proves this with the "delete the heading" drill: break it on purpose once, watch the test fail, restore it, watch it pass. A test you have never seen fail is a test you have never proven. Run that drill for every new test you add.
- Check the behaviour, not just the file. Lab 3's test checks the file exists and holds the heading. A file can exist, hold the heading, and still be broken — for example, an empty page around the heading, or a page the server answers with a 500. The next test to add checks that the page answers with a 200 (success) when asked, not just that the file exists.
- Run the tests locally before pushing. The same commands the pipeline runs can run on your machine first. A push that fails in CI after passing locally is a real difference worth finding; a push that fails in CI because you never ran the tests is a wasted run.
- Test before build, in the pipeline. The order matters: the test step comes before the build step, so a broken site never gets built. That is also the interview answer in the interview pack's question 15 — the same idea, in two places.
And the rule Lab 3 already states, kept word for word in spirit: never replace a missing test with a command that only prints "tests passed". A green pipeline that checked nothing is worse than a red one.
What you can now say, truthfully — advanced
- "I triage incidents by severity and write a timeline while I work — checks, changes, recovery time, and what is still unknown." (Only if you did Advanced 1 and 2, and the error decoder's Advanced section.)
- "I roll back first when a deploy breaks things —
git revert,kubectl rollout undo, or the previous image tag — and I know whylatestcannot be rolled back to." (Only if you did Advanced 3.) - "I can turn a number this kit teaches into an alert —
up == 0for 5 minutes, or Kafka lag growing for 10 — with a runbook first step, and I know what alert fatigue is." (Only if you did Advanced 4.) - "I extended the fake-green-test lesson: a test must be seen to fail, must check behaviour not just files, and must run before the build step." (Only if you did Advanced 6.)
Quick check — try it yourself
Question: What four steps should you follow in order when practising how to fix a broken system?
Open the practice terminal to test this →
Show answer
Break it, read the symptom, find the cause, and then fix it.