DEV Community

Cover image for Docker Explained (Part 1): Understanding Docker Before Writing Your First Command
Ladipo Samuel
Ladipo Samuel

Posted on

Docker Explained (Part 1): Understanding Docker Before Writing Your First Command

Most Docker tutorials start by asking you to install Docker and run your first container. I don't think that's the best way to learn.

If you've ever tried learning a new technology, you've probably experienced this before. You copy commands from a tutorial, everything works, but if someone asks you why it works, you're stuck. You know the syntax, but you don't understand the concept.

Docker deserves better than that.

Before writing a single command, it's important to understand the problem Docker was built to solve. Once you understand the problem, every Docker command starts making sense.

Why Docker Changed Software Engineering

Software engineering has always been about solving problems, but one problem managed to frustrate developers for years.

Imagine you spend days building an application. You install all the required libraries, configure your environment, fix dependency issues, and finally everything works perfectly. You push your code to GitHub, feeling accomplished.

A few minutes later, your teammate clones the project.

  • They install the dependencies.
  • Run the exact same command.
  • And everything breaks.

At first, you think they made a mistake. Then another teammate tries. Same result!!!!

Eventually someone says the sentence almost every developer has heard at least once:

"It works on my machine."

That sentence became a running joke in software engineering, but behind the joke was a real problem.

Every developer's computer is different; one person uses Windows; another uses macOS; someone else develops on Linux; one developer has Python 3.12 installed; another still has Python 3.10; someone upgraded Node.js yesterday; sllomeone else forgot to install PostgreSQL entirely.

Even when everyone follows the same documentation, tiny differences between machines can produce completely different results. The application itself isn't always the problem—the environment is.

As projects became larger and teams became more distributed, this problem became even more expensive. Developers spent hours debugging issues that had nothing to do with their code. Deployments became unpredictable, onboarding new engineers took longer, and production environments often behaved differently from development machines.

Docker didn't just introduce another development tool.

It introduced consistency.

Instead of asking every developer to manually recreate the same environment, Docker packages everything an application needs to run into a portable, isolated environment. Whether it's running on your laptop, your teammate's computer, a CI pipeline, or a production server, the application behaves exactly the same.

That simple idea changed how modern software is built, tested, deployed, and maintained.

What Docker Actually Is?

You'll often hear Docker described as "a containerization platform."

That's technically correct.

It's also not particularly helpful if you're learning Docker for the first time.

Here's a much simpler way to think about it.

Imagine you're speaking at a conference.

Instead of carrying your script in one place, your slides somewhere else, your notes in another folder, and your examples on a flash drive, you put everything into one notebook.

Wherever you go, everything you need goes with you.

Docker does something very similar.

It packages your application together with everything it needs to run.

That includes:

  • Your application code
  • The runtime (like Node.js or Python)
  • Libraries and dependencies
  • Environment configuration
  • System packages required by the application

Instead of depending on whatever already exists on another computer, Docker brings its own environment along.

That's why the same application behaves consistently whether it's running on your machine, your teammate's laptop, or a production server.

Docker isn't replacing your application.

It's making sure your application always has everything it needs to run successfully.

Containers Explained Properly

The word container is probably the first Docker term you'll hear, and it's also one of the most misunderstood. Many tutorials describe a container as "a lightweight virtual machine."

While that comparison helps initially, it's not actually what a container is. A container is simply an isolated environment where your application runs.

Think of it as giving your application its own workspace.

Inside that workspace are all the tools your application needs, but it's isolated from other applications running on the same computer.

That isolation is important.

If one application requires Python 3.12 and another still depends on Python 3.10, they can both run on the same machine without interfering with each other because each container carries its own environment.

Containers are also designed to be temporary. You don't usually modify a running container forever. Instead, if your application changes, you create a new container from an updated image. This makes deployments predictable because every new container starts from the same clean state.

This idea of treating containers as disposable is one of the biggest mindset shifts Docker introduces.

Docker vs Virtual Machines

One of the first comparisons people make is between Docker and Virtual Machines. They solve similar problems, but they solve them very differently.

A Virtual Machine creates an entirely new computer inside your computer.
It includes its own operating system, its own kernel, its own system resources, and everything required to behave like a completely separate machine.

That makes Virtual Machines incredibly powerful, but also heavier. They consume more storage, take longer to start, and require more system resources.

Docker containers take a different approach.

Instead of creating a completely new operating system, containers share the host operating system's kernel while keeping applications isolated from one another.

The result is a much lighter environment that starts in seconds, uses fewer resources, and is easier to distribute.

A simple way to picture it is this:

  • A Virtual Machine is like building a completely separate house on its own piece of land.
  • A Docker Container is like living in your own apartment inside a modern building. You have your own private space, but some infrastructure is shared, making it far more efficient.

That's one of the reasons Docker became so popular. Developers could run multiple isolated applications on the same machine without the overhead of multiple operating systems.

At this point, you should understand why Docker exists, what problem it solves, what a container really is, and why containers became the preferred approach over traditional Virtual Machines.

In Part 2, we'll go one level deeper by exploring Docker's architecture, understanding Images and Containers in depth, and explaining one of the concepts that confuses almost every beginner: what's the real difference between a Docker Image and a Docker Container?

Top comments (1)

Collapse
 
ladipo_samuel_7cfaa827bf5 profile image
Ladipo Samuel

i will drop part 2 later this week and i will love your feedbacks