Skip to main content

Command Palette

Search for a command to run...

Docker Basics

You can call it "Containers 101" if you really insist

Updated
5 min read
Docker Basics
T
TJ Gokken is an AI Systems Architect with a passion for bridging the gap between technology and practical application. Specializing in .NET frameworks and machine learning, TJ helps software teams operationalize AI to drive innovation and efficiency. With over two decades of experience in programming and technology integration, he is a trusted advisor and thought leader in the AI community.

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:

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.

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/ for Windows.

Then open your terminal and type

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 Bourne Again SHell. Yeah, it’s a dad joke in Unix form.

💡
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.

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/macOSBash
Writing portable shell scriptsBash
Managing Windows systemsPowerShell
Need object-based scripting (e.g. JSON, .NET)PowerShell
Following most online tutorialsBash

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?

“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 Time 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.