DEV Community

Audrey Kadjar
Audrey Kadjar

Posted on

πŸ“¦ 🐳 Explaining Docker to My Parents (With Visuals)

Over dinner during the last Christmas holiday, my cousin, who works in maritime logistics, explained his job managing shipping containers. The next day, during a car ride with my parents, I casually mentioned that software engineers also use the concept of "containers" to deliver applications.

My parents asked me to explain. That innocent question sparked an hour-long explanation of Docker in the backseat πŸ˜…

It turned out to be a rewarding experience because it challenged how well I understood it. So, I thought I'd recreate that conversation here (with visuals!) to help others understand Docker.


What's Docker?

β€œDocker? What's that?” my parents asked, intrigued.

Docker is a program you install on your computer. It lets you package your app and everything it needs (code, libraries, settings) into a unit of software called a container.

Developers use Docker to package applications so they can run reliably and consistently.


But why do we need Docker?

β€œOkay, that sounds interesting,” my parents asked, β€œbut what problem does it actually solve?”

The main benefits of using Docker are consistency and speed.

In shipping logistics, containers are used to transport goods from one place to another. The point of using containers is consistency. No matter what’s inside (a couch, TVs, or shoes), it all fits into a standard-sized box that ships easily.

In software engineering, we have a similar concept.

When we deploy an application, we want to package everything it needs - its code, configuration, and dependencies (like libraries) - into a box that can run anywhere.

πŸ“¦ Physical Container       🐳 Docker Container
────────────────────       ─────────────────────
🚒 Shipping Box            πŸ“¦ Docker Container
🧾 Packing List            🧱 Docker Image
πŸ–₯️ TVs                     πŸ’» App Code
πŸ‘Ÿ Shoes                   πŸ“š Libraries
πŸ“˜ Books                   βš™οΈ Config Files
🍽️ Dishes                 πŸ§ͺ Dependencies

πŸ”’ Secure + Sealed         πŸ” Isolated + Portable
🚚 Easy to Transport       πŸ“¦ Easy to Deploy
🌍 Standard Size           πŸ“ Consistent Environment

        ➑️ Goal: Standardize Delivery ⬅️
     πŸ›³οΈ Goods               πŸ§‘β€πŸ’» Software
Enter fullscreen mode Exit fullscreen mode

We work with multiple environments in software engineering: for example, the test environment or the production environment with which customers interact. Docker ensures that your application behaves the same, no matter in which environment it runs.

Unlike older methods like Virtual Machines, Docker doesn’t need to simulate a full operating system, so it's fast.


Wait... What’s a Virtual Machine?

My mom looked back and said: β€œVirtual machine? You lost us there, honey.”

Fair enough! 😁

A virtual machine (VM) allows a physical computer to simulate multiple independent computers within itself. Each VM has its own operating system (OS), virtual CPU, memory, and storage. This setup provides complete separation but is resource-intensive.

Unlike VMs, Docker containers share the host’s operating system instead of running a full OS. Yet, they stay isolated from each other and the host using Linux features like namespaces (for separating processes and networks) and cgroups (for managing resources). This makes containers fast, lightweight, and secure, which is ideal for quick and consistent software deployment.

Image description
(image credit: this diagram was taken from Docker's website)


How is Docker used for delivery?

"Ok, but why do you use this? Why can't you just deploy your application directly?" Another solid question my dad raised with a frown.

In software engineering, we deploy applications to servers to make them accessible to users. A server is just another (usually powerful) computer, often hosted by cloud providers like AWS or Google Cloud. Deploying to a server involves copying your app’s code onto the machine and running it so that others can access your app.

You can deploy your app directly to a serverβ€”but that’s like shipping loose cargo. If the server’s environment is different from yours (like a different library version), your app might not work.

Docker lets you ship your app with its environment. So as long as the server supports Docker, your app runs exactly as it did on your computer.


Demo: How do you use Docker?

At this point, I wasn’t sure if my parents were impressed… or completely lost. Then my mom asked one last question: β€œSo how do you use Docker? It sounds complicated.”

Using Docker is actually pretty straightforward:

  • Install Docker Desktop on your computer.

  • In your app’s folder, create a file called a Dockerfile. In this file, you describe how to package your app β€” specifying the base system, required dependencies, and how to start the app.

This is a simple Dockerfile for a Node.js app:

# Use an official Node.js runtime as the base image
FROM node:18

# Create and set the working directory inside the container
WORKDIR /app

# Copy package.json and package-lock.json
COPY package.json ./

# Install dependencies
RUN npm install

# Copy the rest of your application code
COPY . .

# Expose the port your app runs on
EXPOSE 3000

# Command to run your app
CMD ["node", "index.js"]
Enter fullscreen mode Exit fullscreen mode
  • Build a Docker image:
   docker build -t my-app .
Enter fullscreen mode Exit fullscreen mode

This command creates a Docker image. It’s not a picture but a set of files that contains everything needed to run your app (like a blueprint for creating the container). These files are stored inside Docker’s internal storage area.

  • Run the container:
   docker run my-app
Enter fullscreen mode Exit fullscreen mode

This command starts a container, which is a running instance of the image you built in the previous step.

Your app is now running inside a container!


Hope this guide was helpful! Let me know in the comments what you thought of it and if you have any questions 😊

Top comments (1)

Collapse
 
fyodorio profile image
Fyodor

you are not my son cartoon