# Docker Basics

Docker feels like it is everywhere these days, right? It feels like it is the end all be all solution to everything, regardless of the question.

Docker and the term containers go hand in hand. Containers are exactly what they sound like: Containers. They are packages that contain everything to get your code running regardless of the environment they are in. You can ship it, run it, or break it without messing up your local machine—or your coworker's.

As a developer, chances are you used Virtual Machines (VM) before and you may wonder, how Docker is different to them.

Well, for starters, VMs are heavy - they need the full OS installed and the frameworks, regardless of whether you use them or not.

Containers, on the other hand, are lightweight, meaning they only contain what you need to run your app. No extras.

If I need to use an analogy, the VMs are like houses. They take some time to build and yes, they are awesome when they are built, but if you need 10 of them quickly you need to wait. Containers, are like hotel rooms. You can rent as many as you like for as long as you like and you can checkout anytime you like (but you can never leave).

In a nutshell, containers bring you consistency. If it runs on your machine, it’ll run everywhere (hopefully). They are easy to spin up and discard and the apps run independently - no awkward dependency conflicts.

As you can see, this kind of tool can be very handy, be it in development or in production.

If you made it this far, you probably know where I am going: Docker is a platform that utilizes containers.

Now that we have seen how useful containers can be, let’s see the basic building blocks of Docker.

**Dockerfile**

This is a simple text file telling Docker how to build your container.

Let’s see an example:

```dockerfile
FROM python:3.9
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
```

Here is what the code above means for each line:

1. Start with the official Python 3.9 image as the base. It's like saying “give me a clean machine with Python 3.9 pre-installed.”
    
2. Take everything in your current directory (`.`) and copy it into the `/app` folder *inside* the container.
    
3. Set `/app` as the current working directory inside the container—kind of like `cd /app`.
    
4. Install all the Python packages listed in `requirements.txt`. (OK, for this one it is worth mentioning that Python makes sure that everything in requirements. txt file is installed.)
    
5. This tells Docker what command to run when the container starts. Here, it will run `python` [`app.py`](http://app.py).
    

What you get is a Docker image that can run your Python app with all its dependencies, in a nice clean environment. Run it and boom - your app is live in a container.

**Docker Image**

If you are used to VMs, this is like an ISO image or a zip file. It is the snapshot of your container.

**Docker Container**

The running instance of your Docker image. It's your app, live and kicking.

### Your First Docker Container

OK, this is a bit complicated, so please pay attention.

First, install docker from [https://docs.docker.com/desktop/setup/install/windows-install/](https://docs.docker.com/desktop/setup/install/windows-install/) for Windows.

Then open your terminal and type

```bash
docker run hello-world
```

If you see a friendly message, congratulations - you just officially used Docker.

That’s it. Really. Now we are ready for our Kubernetes journey. We’ll fill in the rest along the way, so buckle up. The seas may be a bit rough but fun.

---

### Appendix A: What is Bash?

You may have realized the language we use in the terminal is called bash and it stands for **B**ourne **A**gain **SH**ell. Yeah, it’s a dad joke in Unix form.

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">You may wonder how is Bourne Again Shell a joke? It is a pun on Stephen Bourne (not related to Jason Bourne), the author of the ancestor of the current Unix shell sh.</div>
</div>

It’s one of the most common command-line shells used on Linux and macOS (and now even on Windows thanks to WSL). When you open a terminal and type commands like `cd`, `ls`, or `echo`, you’re talking to Bash.

Think of Bash as your **text-based butler**—you give it instructions, and it gets things done: move files, run scripts, launch apps, install packages... anything a good butler should know.

It also has scripting powers, which means you can write `.sh` files to automate tasks—like a to-do list Bash will follow line-by-line without needing a second coffee.

At this point, you may wonder how this is different to PowerShell, especially if you are coming from Windows.

Well, Bash is text based, simple and fast and every DevOps tutorial uses it. PowerShell is more verbose but powerful and it is object-oriented meaning everything is an object, not just text.

So when do you use what?

| **If you're...** | **Use...** |
| --- | --- |
| Working on Linux/macOS | **Bash** |
| Writing portable shell scripts | **Bash** |
| Managing Windows systems | **PowerShell** |
| Need object-based scripting (e.g. JSON, .NET) | **PowerShell** |
| Following most online tutorials | **Bash** |

It is worth noting that if you are on Windows, you can now use both thank to Windows Terminal + WSL (Windows Subsystem for Linux) to get the best of both worlds.

---

### Appendix B: Where Does the Name “Docker” Come From?

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1744859024248/6dda7d19-9328-4eaa-bfb5-372767d10986.png align="center")

*“Docker” as in someone who loads and unloads ships.* Containers? Shipping apps? See the connection now?

The whole idea is that Docker helps you "ship" your software in containers that run consistently across machines—like how physical shipping containers standardize how goods move around the world.

So the Docker name fits perfectly: your app is the cargo, Docker is the tool that packages it into a container, and ships it safely across dev, test, and production environments.

And yes, that’s why the logo is a whale carrying shipping containers.

---

### Appendix C: A Brief History of <s>Time </s> Containers

I was going to write a comprehensive history here, but then I Dockerized it — now it boots instantly and no one knows how it works.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1745643129493/63db1d7b-537e-4e4f-bf1a-032038ced9f1.png align="center")
