DevOps Kit Lessons Lesson 10 of 18

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 lessons

Zero-Cost Lab — One Machine, No Cloud Bill

Phase 2 · The Rest of DevOps

What this is and why it matters

This lab sets up your machine and runs your first container: a small sealed box that holds one program.

Think of a lunch box: the food, the spoon, and the box travel together, so lunch tastes the same wherever you open it.

A container is like that for a program: the program and the things it needs travel together, so it runs the same way on different machines.

In real work, programs behave differently on different machines, and that difference wastes hours of fixing.

By the end you can run a tiny web server in a box, stop and start it, save your work online, and write your first script. A script is a small text file full of commands. It runs them one by one for you. A web server is a program that answers a browser and sends it a page.

Your level in Docker & Containers
✓ Step 1 · Beginner→✓ Step 2 · Intermediate→✓ Step 3 · Advanced ← You are here
After this lesson you can: Fix a broken container and prove the web page answers again.
You have finished this topic’s ladder.
Advanced challenge: Container starts then stops — find what holds port 80, run it on a free port. — try it in Zero-Cost Lab.
Your level in Linux, Git & CI/CD
✓ Step 1 · Beginner→✓ Step 2 · Intermediate→✓ Step 3 · Advanced ← You are here
After this lesson you can: Fix a broken script and a failed automated run.
You have finished this topic’s ladder.
Advanced challenge: Deploy script fails — fix the permission and the missing quote, push, watch it pass. — try it in Zero-Cost Lab.

Test status

Syntax-checked only. This lab was NOT run end-to-end on a clean machine yet. Nothing here promises a step works on a real machine. Where a step is unverified, this lesson says so.

What you need

  • A computer with internet.
  • Linux. If you use Windows, install WSL2 with Ubuntu first. WSL2 is Windows Subsystem for Linux. It is a way to run Linux inside Windows.
  • If you use a Mac, the Docker steps below need Docker Desktop instead. Docker Desktop is the Mac (and Windows) app that runs Docker for you.
  • No cloud account. No card. Nothing here costs money. Cloud means renting servers on the internet instead of owning them. You do not need any cloud here.

How to install WSL2 (Windows) and Docker Desktop (Mac) — the missing steps

The lesson says "install WSL2 with Ubuntu first" but gives no steps. Here are the plain steps. They are install steps, not lab steps, and they are unverified in this kit — if they fail, check the official docs for your system.

  • Windows, WSL2: open PowerShell as administrator (right-click PowerShell, choose "Run as administrator"), type wsl --install, press Enter, then restart your computer. After the restart, open Ubuntu from the Start menu. That window is your Linux terminal. wsl --install means: install Windows Subsystem for Linux. Ubuntu is a version of Linux. A terminal is a window where you type commands instead of clicking.
  • Mac, Docker Desktop: go to the Docker website, download Docker Desktop for Mac, open the downloaded file, and drag Docker into Applications. Then open Docker Desktop from Applications and wait until it says it is running. Do NOT run the Ubuntu install commands in Step 2 on a Mac. They are for Linux only.
  • If either install fails, stop here and fix the install first. Nothing later in this lab can work without it.

Open a terminal first

  • Linux: press Ctrl+Alt+T, or find Terminal in your apps.
  • Mac: open the Terminal app.
  • Windows: after WSL2 and Ubuntu are installed, open Ubuntu from the Start menu. That window is your Linux terminal.
  • Ctrl+Alt+T means: hold Ctrl and Alt, then press T.

Words you will see in commands

  • sudo means "run this as the machine's administrator". The administrator is the user who is allowed to change the machine. It may ask for your password. Type your password and press Enter. Nothing shows on screen while you type it. That is normal.
  • apt is Ubuntu's app installer. It downloads and installs programs.
  • ~ means your home folder. Your home folder is the folder that belongs to you, for example /home/learner.
  • systemctl is the tool that starts and stops services. A service is a program that runs in the background for you.
  • $USER means your own username. The computer fills it in for you. You do not type your name there.

A note on the commands

The commands below are well-known, standard Linux commands. They are written for Ubuntu/Debian Linux. On other systems, package names and setup steps can differ — that part is unverified here, so check your system's own Docker docs if a step fails.

How to make a file (you will need this)

Projects and labs ask you to make files like index.html, Dockerfile, and .yml files. index.html is a web page file. Dockerfile is a recipe file for building an image. A .yml file holds settings in YAML. YAML is a plain-text way of writing settings with indentation. Spaces matter. Never use the Tab key in a .yml or .yaml file. If a YAML file fails with a strange error, check the spaces first.

Two easy ways to make a file:

Way 1 — with a text editor

  • WHAT it is: nano is a simple text editor that runs inside the terminal.
  • WHY we use it: you can see the text, change it, and save it.
  • Type nano index.html, write your text, press Ctrl+O then Enter to save, Ctrl+X to leave. Ctrl+O means hold Ctrl and press O. Ctrl+X means hold Ctrl and press X.

Way 2 — straight from the terminal (good for short files)

  • WHAT it is: cat > index.html << 'EOF' writes the lines that follow into a file, until it sees the line EOF.
  • WHY we use it: it is fast for short files, and you can copy it exactly.
  • Word by word: cat is a command that prints files. > means "write the output into a file instead of printing it". index.html is the file name. << 'EOF' means "read the lines below until a line that says exactly EOF". EOF means "end of file". It is just a marker word. You could use another word, but every example in this kit uses EOF.
Try it Yourself »Open the practice terminal and run it yourself — nothing installs. Included with Phase 2. Simulation — practice version. Run the real lab with Docker to do it for real.
Command
cat > index.html << 'EOF'
<h1>My site</h1>
<p>Learning DevOps, one project at a time.</p>
EOF

You should see: nothing. The file is written silently. That is normal. How to check it worked: run cat index.html.

  • WHAT cat index.html is: print the file called index.html.
  • WHY: if it holds your two lines, the file was written.
  • You should see your two lines printed back.

Step 1 — Check what you already have

  • WHAT we are doing: asking the machine "do you already have Git and Docker, and which version?"
  • WHY: if they are already installed, you skip Step 2. If not, Step 2 installs them.
Command
git --version
docker --version
  • Word by word: git is the version-saving tool. --version means "print your version number, do not do anything else". docker is the container tool. --version means the same.

You should see:

Command
git version 2.43.0
Docker version 27.5.1, build 9f9e405

How to tell it worked: each line shows a version number, like 2.43.0. Your numbers will be different. That is fine. What matters is a version number, not an error.

If it breaks: "command not found" for either one means it is not installed. Go to Step 2 for the missing one. If both print a version number, skip to Step 3. Step 2 is Linux-terminal only. On a Mac, do not run Step 2. Install Git and Docker Desktop, then go to Step 3.

Step 2 — Install Git and Docker (Ubuntu/Debian only)

  • WHAT we are doing: installing two programs on Ubuntu or Debian Linux.
  • WHY: Step 1 showed one of them is missing, and nothing later works without them.
  • This step is for a Linux terminal only: Ubuntu or Debian directly, or WSL2 Ubuntu on Windows. On a Mac, do NOT run these commands. Install Git and Docker Desktop, then go to Step 3.
  • Ubuntu and Debian are two versions of Linux. The commands below are written for them. On other systems, package names and setup steps can differ. That part is unverified here, so check your system's own Docker docs if a step fails.
Command
sudo apt update
sudo apt install -y git docker.io
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
  • Line 1: sudo apt update.
  • WHAT: ask the app installer to download the newest list of programs it can install.
  • WHY: without a fresh list, the installer may say a program does not exist when it does.
  • Word by word: sudo (as administrator) + apt (the installer) + update (refresh the list).
  • Line 2: sudo apt install -y git docker.io.
  • WHAT: install Git and Docker.
  • WHY: these are the two tools this lab needs.
  • Word by word: sudo (as administrator) + apt install (install with the installer) + -y (say "yes" to every question, so it does not stop and ask you) + git (the version-saving tool) + docker.io (the Docker program, as Ubuntu names it).
  • docker.io is just Ubuntu's name for the Docker package. It is the same Docker you use in later steps.
  • Line 3: sudo systemctl enable --now docker.
  • WHAT: start Docker now, and set it to start by itself every time the machine starts.
  • WHY: Docker is a service that must be running before any docker command can work.
  • Word by word: sudo (as administrator) + systemctl (the service tool) + enable (start by itself on every boot) + --now (also start it right now) + docker (the Docker service).
  • Line 4: sudo usermod -aG docker $USER.
  • WHAT: add your user to the docker group.
  • WHY: only then can you run Docker without typing sudo each time. A group is a list of users who are allowed to do something. The docker group is the list of users allowed to use Docker.
  • Word by word: sudo (as administrator) + usermod (change a user) + -aG (add to a group, keeping the groups the user already has) + docker (the group name) + $USER (your own username, filled in by the computer).
  • This step only takes effect after you open a fresh terminal, or log out and back in. Your old terminal window does not know yet.

You should see: lines scroll past as programs download and install. At the end, your prompt comes back with no error. The prompt is the line that waits for your next command.

If it breaks: "Unable to locate package docker.io" means the program list is stale. Run sudo apt update again, then retry the install. "Permission denied" means you forgot sudo. Run the command again with sudo in front.

Warning, read this: being in the Docker group effectively gives control of this Linux machine at the administrator level. That means a Docker command could change anything on the machine, the way an administrator could. Use it only on a machine you control. On a shared machine, follow the administrator's rules instead. Docker's rootless mode is the safer option there. Rootless mode means Docker runs without administrator power.

Then close the terminal, open it again, and run:

Command
docker --version
  • WHAT: ask Docker for its version number, in a fresh terminal.
  • WHY: the fresh terminal is the test that the group change worked. The old terminal does not know about the group yet.

You should see:

Command
Docker version 27.5.1, build 9f9e405

Your version number will be different. That is fine.

If it breaks: "command not found" means the install did not finish. Go back and run the four install commands again.

Step 3 — Prove Docker works

  • WHAT we are doing: running a tiny test image that prints one message and stops.
  • WHY: it proves Docker is installed and running, before you try a real app.
Command
docker run hello-world
  • Word by word: docker (the container tool) + run (start a container) + hello-world (the name of the tiny test image). An image is a saved, ready-to-run copy of a program. Docker downloads hello-world from Docker Hub the first time. Docker Hub is the public place where ready-made images live.

You should see a message saying Docker is working:

Command
Hello from Docker!
This message shows that your installation appears to be working correctly.

How to tell it worked: you see the words "Hello from Docker!". If you see that, Docker works. The rest of the message is detail.

If it breaks: the most common cause is that Docker is not running. On a Linux terminal, run sudo systemctl start docker and try again.

  • WHAT sudo systemctl start docker is: start the Docker service right now, as administrator.
  • WHY: Docker must be running before docker run can work. On Docker Desktop (Mac, or Windows outside WSL2), open Docker Desktop instead. systemctl does not apply there. There is no systemctl on a Mac.
  • If the error says "permission denied", your terminal session has not picked up the Docker group yet. Run newgrp docker, or close the terminal and open it again, then retry.
  • WHAT newgrp docker is: switch this terminal into the docker group right now, without closing it.
  • WHY: it is a faster way to pick up the group change from Step 2.

Step 4 — Run your first real container

  • WHAT we are doing: starting a small web server called nginx in a container, in the background.
  • WHY: this is your first real container. It stays running, and you can open it in a browser.
  • nginx (say "engine-x") is a small, well-known web server program. A web server is a program that answers a browser and sends it a page.
Command
docker run -d -p 8080:80 --name my-site nginx
  • Word by word: docker run (start a container) + -d (run in the background, so your terminal stays free) + -p 8080:80 (connect door 8080 on your machine to door 80 inside the container) + --name my-site (call this container my-site, so you can refer to it by name later) + nginx (the web server program to run).
  • A port is just a numbered door for network traffic. Door 80 is the door web servers normally listen on, inside the box. Door 8080 is the door you open on your own machine, so it does not clash with anything else.
  • -d means detached. Detached means "run in the background".

You should see: a long container ID printed (a string of letters and numbers), then your prompt back. A container ID is a unique code for this container, like a receipt number. You do not need to remember it. The name my-site is what you will use. The container runs in the background. Nothing else prints.

If it breaks: "port is already allocated" means something already uses port 8080. Stop that container first, or run with -p 8081:80 instead and open http://localhost:8081.

  • WHAT -p 8081:80 is: same box, but door 8081 on your machine instead of 8080.
  • WHY: two programs cannot use the same door at the same time.

Now open your browser and go to http://localhost:8080. localhost means "this machine". It is your own computer. http:// means "ask for a web page". 8080 is the door number. You should see the nginx welcome page. The welcome page says "Welcome to nginx!". If you see it, your container is running and your browser can reach it.

Step 5 — Look at it and stop it

  • WHAT we are doing: listing running containers, stopping ours, and listing again to prove it stopped.
  • WHY: starting is only half the skill. You must also be able to see what is running and stop it.
Command
docker ps
docker stop my-site
docker ps
  • Line 1: docker ps.
  • WHAT: list running containers.
  • WHY: to see my-site running, before you stop it.
  • Word by word: docker (the container tool) + ps (list processes — here, list containers that are running).
  • Line 2: docker stop my-site.
  • WHAT: stop the container called my-site.
  • WHY: to prove you can stop it, and to free door 8080.
  • Word by word: docker + stop (stop it) + my-site (the container's name).
  • Line 3: docker ps again.
  • WHAT: list running containers a second time.
  • WHY: to prove my-site is gone from the list.

You should see: the first docker ps lists my-site as Up:

Command
CONTAINER ID   IMAGE     STATUS         PORTS                  NAMES
abc123def456   nginx     Up 5 seconds   0.0.0.0:8080->80/tcp   my-site

How to read this line, column by column:

  • CONTAINER ID (abc123def456): the short code for this container. Yours will be different. That is fine.
  • IMAGE (nginx): the image this container was started from.
  • STATUS (Up 5 seconds): the container is running, and has been running for 5 seconds. Yours will say a different number of seconds.
  • PORTS (0.0.0.0:8080->80/tcp): door 8080 on your machine leads to door 80 in the container. 0.0.0.0 means "all addresses on this machine". tcp is the kind of network traffic.
  • NAMES (my-site): the name you gave it.

After docker stop, the second docker ps should no longer list my-site. Your container is stopped. Other running containers may still appear. That is fine. Only my-site should be gone.

To start it again later: docker start my-site.

  • WHAT: start a stopped container again.
  • WHY: stopping does not delete it. You can bring it back. To remove it fully: docker rm my-site.
  • WHAT: delete the stopped container.
  • WHY: after this, the name my-site is free to use again.
  • rm means remove. Only run it after the container is stopped.

If it breaks: if my-site still shows after the stop, wait a few seconds and run docker ps again. A stop takes a moment.

Step 6 — Make a folder for your work

  • WHAT we are doing: making one folder where all later labs and projects live.
  • WHY: every later lab tells you to work inside this folder. If you skip it, later steps will say "no such file or directory".
  • This folder does NOT already exist in the kit. You create it now. It is a learner-created folder, on your machine.
Command
mkdir -p ~/devops-practice
cd ~/devops-practice
  • Line 1: mkdir -p ~/devops-practice.
  • WHAT: make a folder called devops-practice inside your home folder.
  • WHY: this is the one place for all your practice work.
  • Word by word: mkdir (make a directory — a directory is a folder) + -p (make any missing parent folders too, and do not complain if the folder already exists) + ~/devops-practice (your home folder, then a folder called devops-practice).
  • Line 2: cd ~/devops-practice.
  • WHAT: move into that folder.
  • WHY: every command after this runs inside it, until you move somewhere else.
  • Word by word: cd (change directory — move to another folder) + ~/devops-practice (the folder to move into).

You should see: nothing. These commands print nothing when they work. That is normal.

If it breaks: "No such file or directory" means the folder name is wrong. Run pwd to see where you are, then try again.

  • WHAT pwd is: print the folder you are in right now.
  • WHY: it tells you where you are, so you can see what went wrong.
  • pwd means "print working directory". Your working directory is the folder you are in.

All later labs and projects in this kit live in this folder.

Step 7 — Put your work on GitHub (first time only)

  • WHAT we are doing: saving your work on GitHub, so it lives online and not only on your machine.
  • WHY: GitHub is where your work is stored and shown. The projects ask you to "push to GitHub". This step does that setup once.
  • GitHub is a website that stores Git work online. A repository is a folder on GitHub that holds your project. People usually say "repo" for short.
  • Do this once, the first time. Later pushes are shorter (see the end of this step).

7a. Make the repository on GitHub

  1. Make a free account on github.com, if you do not have one.
  2. Sign in. Click the "+" or "New" button, then "New repository".
  3. Give it a name, for example devops-practice.
  4. Leave it public or private — your choice. Public means anyone can see it. Private means only you can see it.
  5. Do NOT tick "Add a README file". Leave the repository empty. If GitHub adds a file, your first push below will clash with it.
  6. Click "Create repository".
  7. GitHub will show you the repository's address. Copy it. It looks like this: https://github.com/<you>/<repo>.git <you> is your GitHub username. <repo> is the repository name. For example: https://github.com/learner/devops-practice.git Do not type the < and > brackets. They only mark the parts you replace.

7b. Start tracking the folder, then check Git knows who you are

In your terminal, from inside your project folder (~/devops-practice, from Step 6), run git init first — Git does nothing in a folder until you start tracking it:

Command
git init
  • WHAT: start tracking this folder with Git.
  • WHY: until you do this, Git does not watch the folder at all. Every Git command after this one — including git status below — needs this step first.
  • Word by word: git (the tool) + init (start, short for initialise).

Then check Git knows who you are:

Command
git config user.name
git config user.email
  • WHAT: ask Git "what name and email have you saved for me?"
  • WHY: every save (commit) is stamped with a name and email. If Git does not know them, it will refuse to save.
  • Word by word: git config (show or change a Git setting) + user.name (the name setting) and user.email (the email setting).

If either prints nothing, set them. Use an email you are comfortable attaching to your commits (it will be visible on public work). Run these two lines, replacing the examples with your own details:

Command
git config --global user.name "Learner"
git config --global user.email "learner@example.com"
  • WHAT: save your name and email for all Git work on this machine.
  • WHY: Git needs them before your first commit.
  • Word by word: git config (change a setting) + --global (for all projects on this machine, not just this folder) + user.name (the name setting) + "Learner" (the name to save — use your own).

Then run git status to see what would be staged.

  • WHAT git status is: show what has changed and what would be saved next.
  • WHY: it shows you what you are about to send, before you send it.
  • Staged means "marked to be saved in the next commit".
  • Make a .gitignore file first if the folder holds anything private (passwords, keys, Terraform state files). Never stage those.
  • WHAT a .gitignore file is: a file that lists files Git must never save or send. Its name starts with a dot, so it is a hidden file.
  • HOW to make one: cat > .gitignore << 'EOF', then one file name per line, then EOF on its own line. For example, a line that says *.pem tells Git to ignore every file ending in .pem.
  • WHY: passwords, keys, and state files must never go to GitHub.

7c. Make a sign-in token (before the first push)

GitHub stopped accepting your normal GitHub password for pushes. You need a personal access token instead. A token is a long secret code that stands in for your password when Git talks to GitHub. Treat it like a password: never paste it into a chat, never save it in a file you push to GitHub.

  1. On github.com, click your profile photo (top-right), then Settings. In the left list, near the bottom, click Developer settings. Then click Personal access tokens, then Tokens (classic).
  2. Click Generate new token, then Generate new token (classic). Give it a name, for example devops-practice. Tick the repo scope only — that is the one that lets you push and pull. Leave the rest unticked. Click Generate token.
  3. Copy the token now. GitHub shows it only once, on this page. If you close the page without copying it, you cannot see it again — you must make a new one.
  4. Tell Git to remember it, so you are not asked every time. Run:
Command
git config --global credential.helper store
  • WHAT: save your GitHub sign-in so Git remembers it.
  • WHY: without this, Git asks for your username and token on every push. With it, the first push saves them and later pushes just work.
  • Word by word: git config (change a Git setting) + --global (for all projects on this machine) + credential.helper (the setting that says how Git stores sign-ins) + store (save them in a file on your own machine).
  • Honest note: store saves the token in a plain file on your own machine. That is fine on your own computer, but do not use it on a shared machine. On Windows and Mac, Git usually remembers your sign-in by itself without this step — run the command anyway, so it works the same everywhere.

When the first push asks for your sign-in, type your GitHub username as the username, and paste the token as the password — never your GitHub password. If the push accepts it, the token is saved and later pushes will not ask again.

7d. Send your work to GitHub

Command
git add .
git commit -m "first commit"
git branch -M main
git remote add origin <your repository address>
git push -u origin main
  • Line 1: git add ..
  • WHAT: stage everything in this folder.
  • WHY: staging marks files to be saved in the next commit.
  • Word by word: git + add (stage) + . (this folder — the dot means "here").
  • Line 2: git commit -m "first commit".
  • WHAT: save the staged files, with the message "first commit".
  • WHY: a commit is a saved snapshot. The message says what changed.
  • Word by word: git + commit (save a snapshot) + -m (the message follows) + "first commit" (the message text).
  • Line 3: git branch -M main.
  • WHAT: name your main line of work "main".
  • WHY: GitHub expects the main line to be called main.
  • Word by word: git + branch (work with lines of work) + -M (rename, even if the name already exists) + main (the name).
  • A branch is a separate line of work. main is the main line.
  • Line 4: git remote add origin <your repository address>.
  • WHAT: connect your folder to the GitHub repository you made.
  • WHY: Git needs to know where "online" is before it can send anything there.
  • Word by word: git + remote (a far-away copy) + add (add one) + origin (the nickname for your GitHub copy — the usual nickname) + <your repository address> (the address you copied in 7a — replace the whole thing, brackets included, with the real address).
  • Line 5: git push -u origin main.
  • WHAT: send your main line to GitHub, and remember the link.
  • WHY: this is the step that actually puts your work online.
  • Word by word: git + push (send) + -u (remember this link, so later pushes need no extra words) + origin (your GitHub copy) + main (the line to send).

You should see: a commit line, then the push lines:

Command
[main (root-commit) abc1234] first commit
 1 file changed, 1 insertion(+)
To https://github.com/<you>/<repo>.git
 * [new branch]      main -> main

How to read this, line by line:

  • [main (root-commit) abc1234] first commit: your first save, on the main line, with the message "first commit". abc1234 is the short code for this save. Yours will be different.
  • 1 file changed, 1 insertion(+): one file was saved, with one new line in it. Your numbers will be different.
  • To https://github.com/<you>/<repo>.git: the work was sent to your repository address. Yours will show your own username and repository name.
  • * [new branch] main -> main: GitHub received a new main line. The arrow means "your main went to GitHub's main".

If it breaks: "Permission denied" or "Authentication failed" means GitHub did not accept your sign-in. Most often the token is wrong, expired, or you typed your GitHub password instead of the token. GitHub does not accept your normal password for pushes any more — only the token works. Make a fresh token as in 7c above, and try the push again. If GitHub says "Support for password authentication was removed", that is the same problem: paste the token as the password. "src refspec main does not match any" means the commit never happened. Run git status and check your files were staged.

After this first push, later pushes are just three lines:

Command
git add .
git commit -m "message"
git push

Replace "message" with a short note about what you changed. git push alone works now because -u in the first push remembered the link.

Step 8 — Your first script

  • WHAT we are doing: making a small file that checks your Docker containers, making it runnable, and running it.
  • WHY: a script saves you typing the same commands again and again. This one is a useful check you will run often.
Command
cat > health-check.sh << 'EOF'
#!/bin/bash
echo "Running containers:"
docker ps --format "{{.Names}} is {{.Status}}"
EOF
chmod +x health-check.sh
./health-check.sh
  • Lines 1 to 5: cat > health-check.sh << 'EOF' … EOF.
  • WHAT: write the lines between the markers into a file called health-check.sh. (See "How to make a file" above for how cat > and EOF work.)
  • WHY: this creates the script file.
  • 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. It is called a shebang line. You type it exactly as shown.
  • echo "Running containers:" — WHAT: print the words "Running containers:". WHY: so you can see a heading before the list. echo means "print this".
  • docker ps --format "{{.Names}} is {{.Status}}" — WHAT: list running containers, but print only each name and status, in the form "NAME is STATUS". WHY: the normal docker ps table is wide. This short form is easier to read. Word by word: docker ps (list running containers) + --format (print in this shape, not the table) + "{{.Names}} is {{.Status}}" (the shape: the container's name, then the word "is", then its status).
  • Line 6: chmod +x health-check.sh.
  • WHAT: mark the file as runnable.
  • WHY: a new text file is not runnable yet. The computer will refuse to run it until you mark it.
  • Word by word: chmod (change the file's mode — its permissions) + +x (add the "can run" permission) + health-check.sh (the file).
  • Line 7: ./health-check.sh.
  • WHAT: run the file in this folder.
  • WHY: this is the step that actually runs your script.
  • Word by word: ./ means "in this folder". health-check.sh is the file. Together they mean "run the file called health-check.sh that sits in this folder".

You should see:

Command
Running containers:
my-site is Up 2 minutes

How to read it: the first line is the heading your script printed. The second line says the container my-site is Up, and has been running for 2 minutes. Your container names and times will be different. That is fine. If no containers are running, only the first line prints. That means the script worked, but nothing is running.

If it breaks: "permission denied" usually means the file is not marked runnable yet. Run chmod +x health-check.sh and try again. But the same error can also come from the wrong owner, a folder you cannot enter, or a disk that forbids running files. If the error names a missing interpreter instead, check the first line of the script (#!/bin/bash) and whether that program is installed.

If something goes wrong

  1. Read the error message fully before searching for help.
  2. docker ps -a shows stopped containers too. Useful when a container died.
  3. WHAT: docker ps lists running containers. -a means "all" — include stopped ones too.
  4. WHY: a dead container disappears from plain docker ps, but still shows in docker ps -a, so you can see what happened to it.
  5. docker logs my-site shows what a container printed before it stopped.
  6. WHAT: print the lines a container printed.
  7. WHY: those lines usually name the problem.
  8. Start with the error message and the container's status. For a container that stopped, docker logs is usually the next look. For a container that never started, the error Docker printed is the evidence. There may be no logs at all, because there is no container to read logs from.
  9. Docker itself confused? Three different problems, three checks:
  10. docker --version prints nothing: the Docker program is missing. Install it (Step 2).
  11. docker ps says it cannot connect: Docker is installed but not running. Start it (Linux terminal: systemctl; Docker Desktop: open the app).
  12. docker ps works but a command says "permission denied": your terminal has not picked up the Docker group. Run newgrp docker or open a fresh terminal.

What costs money (so you can avoid it)

Cloud servers, hosted Kubernetes, and paid course platforms cost money. Nothing in this lab needs them. If a later step in this kit mentions a cloud service, it will say so clearly and give a local alternative first. Local means on your own machine, with no bill.

What comes next

You can now run Docker. Do the break-and-fix labs as you learn each tool, then build the portfolio projects. When you can run Docker and read logs, Phase 1 is next: Kafka, PostgreSQL, Redis, Moto and a load balancer, ending with an end-to-end lab where a fake order flows through all of them at once. End-to-end means from the first step to the last step, all together.

Sources

  • Docker's official getting-started guide — https://docs.docker.com/get-started — the toolmaker's own first steps for Docker, in order.
  • freeCodeCamp — https://www.freecodecamp.org — free written guides and video series on Linux, Docker, and Kubernetes basics.
  • TechWorld with Nana (YouTube) — https://www.youtube.com/@TechWorldwithNana — slow, visual explanations of Docker, Kubernetes, and CI/CD ideas, with diagrams.

Advanced — Build your own image from a Dockerfile

This section is for the reader who already did the lab above. It is the Dockerfile build the Phase 2 start page promises and this lab never does: Step 4 runs a ready-made nginx image, but you never build one of your own. The commands are standard Docker and match the images this kit already uses, but this section was not run end to end on this kit — if a step differs on your machine, read the error line first, as this lab teaches.

Advanced 1 — Your first Dockerfile build

What this is: a Dockerfile is a recipe file for building an image, as this lab already defines it. docker build reads the recipe and makes the image. Why we do it: every image in this kit started as a Dockerfile — the object-store lab and the end-to-end lab both build small images from one. Running ready-made images teaches you to use Docker; building one teaches you to ship with it.

Do this inside your work folder from Step 6. First, make a web page. Type this, then press Enter:

Command
cat > index.html << 'EOF'
<html>
<body>
<h1>My DevOps practice site</h1>
<p>Built by me, in my own image.</p>
</body>
</html>
EOF

Word by word: this is the heredoc file-making way this lab already teaches (Way 2, under "How to make a file"). cat > index.html writes the lines that follow into a file called index.html. << 'EOF' means "read the lines until a line that says EOF". The page says "My DevOps practice site" — the same heading the pipeline test in the break-and-fix labs checks for.

Then make the recipe. Type this, then press Enter:

Command
cat > Dockerfile << 'EOF'
FROM nginx:1.27-alpine
COPY index.html /usr/share/nginx/html/index.html
EOF

Word by word:

  • FROM nginx:1.27-alpine — start from the nginx image, version 1.27-alpine. FROM means "start from this image". The version is pinned — 1.27-alpine, not nginx with no tag — for the reason in Advanced 2 below. This is the same image the load balancer lab already uses.
  • COPY index.html /usr/share/nginx/html/index.html — copy your page into the image, replacing nginx's welcome page. /usr/share/nginx/html/ is where nginx looks for pages. COPY means "copy a file from your folder into the image".

Check both files exist:

Command
ls

What you should see: Dockerfile and index.html in the list. Now build the image. Type this, then press Enter:

Command
docker build -t my-site:1.0 .

Word by word:

  • docker build — build an image from a recipe.
  • -t my-site:1.0 — name the image my-site and label it version 1.0. -t means tag (name it). The :1.0 is your own version label — change it when the site changes, so you always know which version is running.
  • . — the build folder is this folder, the one your terminal is in right now. A single dot means "here". Docker reads the Dockerfile in this folder.

What you should see: lines starting with Step 1/2 and Step 2/2, then Successfully tagged my-site:1.0 (the exact words differ slightly by Docker version — what matters is the success line naming your image). If it breaks: Dockerfile not found means your terminal is in the wrong folder — move into the folder with the Dockerfile first. failed to solve with a network error means Docker cannot download the base image — check your internet connection.

Run your image. Type this, then press Enter:

Command
docker run -d -p 8080:80 --name my-site my-site:1.0

Word by word: this is the same docker run shape as Step 4, but the image is yours now: my-site:1.0 instead of nginx. Open http://localhost:8080 in your browser. What you should see: your page — "My DevOps practice site" — not the nginx welcome page. If you see the welcome page, an old container is still holding port 8080: stop it with docker stop my-site and docker rm my-site first, then run yours again.

Now change the page and rebuild. Open index.html, change the heading, save, and run the build command again:

Command
docker build -t my-site:1.1 .
docker rm -f my-site
docker run -d -p 8080:80 --name my-site my-site:1.1

Word by word: the new tag 1.1 marks the new version. docker rm -f my-site removes the old running container (-f means force: stop it and remove it in one step). Then run the new version. Refresh the browser: the new heading is there. That loop — change, build, tag, run — is the whole Docker workflow.

Advanced 2 — Dockerfile gotchas, hands on

What this is: the mistakes every beginner makes with Dockerfiles. Why learn them here: each one is cheap to learn now and expensive to learn in production.

  • Pin the tag, always. FROM nginx:1.27-alpine pins the version. FROM nginx with no tag means "the newest version" — and the newest version moves under you. A build that worked yesterday can break today, with nothing changed in your file. Every compose file in this kit pins its images for exactly this reason.
  • Order the layers for the cache. Docker rebuilds a layer whenever a layer above it changed. The rule: copy the dependency list first, install dependencies, then copy your code last. Change one line of code and only the last layer rebuilds. Copy your code first and every change reinstalls everything.
  • Keep the build folder small. docker build . sends the whole folder to Docker. A .dockerignore file lists what to leave out — .git, secrets, big data files — the same idea as .gitignore, for the build. Without it, a stray 2 GB file in the folder is sent on every build.
  • Never bake a secret into the image. A password or key copied into the image stays in the image forever, and anyone with the image can read it. Secrets come from the environment or a secrets store at run time, never from the Dockerfile. (The practice passwords in this kit's compose files are learning shortcuts on your own machine — the rule still stands for real work.)
  • One process per container. A container runs one main program. If you need two programs, run two containers. That is why this kit's labs have one container per service.
  • The image runs as root by default. Name it as a risk: a process running as root inside a container that escapes is a process running as root on the machine. The fix is the USER instruction in the Dockerfile — set the user the container runs as — at concept level for now.

Advanced 3 — Restart policies

What this is: a restart policy tells Docker what to do when a container stops by itself. Why it matters: your my-site container above has no policy — if it crashes, it stays dead until you notice.

On the command line the policy is a flag:

Command
docker run -d -p 8080:80 --restart unless-stopped --name my-site my-site:1.0

In a Compose file it is a line, and the end-to-end lab already uses it on its ingest and worker services: restart: unless-stopped. The four values, in plain words:

  • no — the default. Never restart. Right for one-off jobs, wrong for anything that must stay up.
  • always — restart it every time it stops, even if you stopped it on purpose, and start it again when Docker itself restarts.
  • unless-stopped — like always, but if you stopped it on purpose, it stays stopped. This is the usual right answer for long-running services.
  • on-failure — restart it only if it stopped with an error. You can add a retry count: on-failure:3 means try three times, then stop.

The rule: every container that must stay up gets a restart policy. A container with no policy is a service that dies quietly at 3am.

What you can now say, truthfully — advanced

  • "I built my own Docker image from a Dockerfile — pinned base image, my own page copied in — tagged it my-site:1.0, ran it, changed the page, and rebuilt it as 1.1." (Only if you did Advanced 1.)
  • "I know the Dockerfile gotchas: pin the tag, order the layers for the cache, ignore the junk, never bake in a secret." (Only if you did Advanced 2.)
  • "I can explain the four restart policies and why unless-stopped is the usual right answer." (Only if you did Advanced 3.)

Quick check — try it yourself

Question: Why do people run a program inside a container (a small sealed box)?

Open the practice terminal to test this →

Show answer

A container keeps one program inside a sealed box so it runs the same way on different computers without wasting hours debugging differences.