Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

What Is Docker and Why Is It So Popular?

· 6 min read · Home Tech

In this article
  1. Background: Where Docker Came From
  2. How Docker Works: Images, Containers, and the Engine
  3. Why Docker Is So Popular: The Key Benefits
  4. Common Problems and Misconceptions
  5. How to Choose: Docker vs. Alternatives
  6. Costs and Safety Considerations
  7. Frequently Asked Questions

Docker is a software platform that packages applications into lightweight, portable containers that run consistently on any system that has Docker installed. It became wildly popular because it solves the classic “works on my machine” problem: a container bundles your code, runtime, libraries, and settings into one unit that behaves the same on a laptop, a server, or a cloud VM. Instead of installing dependencies manually and hoping versions match, you build an image once and run it anywhere.

Background: Where Docker Came From

Docker was released in 2013 by a company called Dotcloud (later renamed Docker Inc.). It built on existing Linux kernel features—namespaces for isolating processes and cgroups for limiting resource usage—that had been around for years. What Docker added was a user-friendly layer: a command-line tool, a standard image format, and a registry (Docker Hub) to share images. Before Docker, container technology like LXC existed but was cumbersome and not widely adopted outside big tech companies. Docker made containers feel like a normal developer tool, similar to Git or npm.

How Docker Works: Images, Containers, and the Engine

At its core, Docker has three main concepts:

  • Dockerfile – a text file that lists the steps to build an image. For example, FROM node:18 starts from a base image, then COPY . /app copies your code, and CMD ["npm", "start"] defines the command to run.
  • Image – an immutable snapshot of the filesystem, libraries, and configuration. You can build it once and share it via a registry.
  • Container – a running instance of an image. It’s isolated from the host OS but shares the kernel, so it starts in seconds and uses minimal memory.

The Docker engine (the daemon) manages images, containers, networks, and volumes. When you run docker run -p 8080:80 nginx, it pulls the Nginx image, creates a container, and maps port 8080 on your host to port 80 inside the container. The container sees its own filesystem and network namespace, but it’s just a process on the host.

Docker’s popularity comes from a few concrete advantages that developers and ops teams feel daily:

  • Consistency across environments – the same image runs identically on a developer’s Windows laptop and a Linux production server. No more “but it worked in my environment.”
  • Fast startup and low overhead – containers share the host OS kernel, so they don’t need a full operating system like virtual machines. A container can start in under a second, and you can run dozens on a single server.
  • Simplified dependencies – you don’t install Python, Redis, or PostgreSQL directly on your machine. You run them as containers. That keeps your host clean and lets you switch versions easily.
  • Reproducible builds – a Dockerfile is a recipe. Anyone on your team can build the same image, and CI/CD pipelines use the same process.
  • Easy scaling – when you need more instances, you just run more containers. Orchestrators like Kubernetes or Docker Swarm handle the distribution.

These benefits made Docker the default choice for microservices, local development, and cloud deployments.

Common Problems and Misconceptions

Docker isn’t magic, and new users often hit a few pitfalls:

  • “Docker is a VM” – No. Containers share the host kernel, so they can’t run a different OS (e.g., you can’t run a Linux container on a Windows kernel without a Linux VM underneath). On macOS and Windows, Docker Desktop runs a lightweight Linux VM to provide the kernel.
  • Data loss – containers are ephemeral. If you write files inside a container and it’s deleted, the data is gone. You must use volumes or bind mounts to persist data (e.g., docker run -v /host/path:/container/path).
  • Image bloat – a careless Dockerfile can produce a 2 GB image. Using a slim base image (like alpine) and multi-stage builds keeps images small.
  • Security – running as root inside a container is common but risky. Use USER in the Dockerfile, and avoid untrusted images from public registries unless you scan them.

A frequent question is: “Do I need Docker for a small project?” If you’re just testing a simple script, probably not. But if you have multiple services (database, backend, frontend) or want to share your setup with others, Docker saves time.

How to Choose: Docker vs. Alternatives

Docker is not the only container tool. Here’s how to decide:

  • Docker vs. Podman – Podman is a daemonless alternative that runs containers as regular user processes. It’s more secure by default and uses the same OCI images. If you’re on a system where you can’t run a daemon (like certain CI environments), Podman is a good choice.
  • Docker vs. LXD – LXD is a system container manager that runs full Linux distributions, more like lightweight VMs. It’s useful for running entire OSes, but less common for application development.
  • Docker vs. Kubernetes – Kubernetes is an orchestrator, not a container runtime. It manages many containers across multiple machines. Docker is often used to build and run containers; Kubernetes schedules them. You can use Docker alone for a single server, but for scaling across a cluster, you need an orchestrator.

For most developers, Docker is the safest default because it has the largest ecosystem, best documentation, and is supported by every major cloud provider.

Costs and Safety Considerations

Docker itself is free and open-source. The Docker Engine is Apache 2.0 licensed. However, Docker Desktop for Windows and macOS is free for small businesses (under 250 employees and under $10M revenue) but requires a paid subscription for larger companies. That’s a common surprise. If you need a free alternative on desktop, Podman Desktop or Rancher Desktop work well.

Safety-wise, Docker containers are not a security boundary. A container shares the kernel with the host, so a vulnerability in the kernel or a misconfigured container can affect the host. Always:

  • Run containers with the least privileges needed (--user or USER in Dockerfile).
  • Only use images from trusted sources and scan them for vulnerabilities (e.g., docker scan or Trivy).
  • Keep the Docker engine and base images updated.
  • Never expose the Docker socket (/var/run/docker.sock) to untrusted containers—that gives them root access to the host.

Frequently Asked Questions

What is the difference between Docker and a virtual machine?

A virtual machine (VM) runs a full guest operating system on top of a hypervisor, which uses a lot of resources (CPU, RAM, disk). A Docker container shares the host’s kernel and only includes the application and its dependencies. Containers start in milliseconds and use megabytes, while VMs take minutes and gigabytes. However, VMs provide stronger isolation because each has its own kernel.

Do I need to learn Docker to be a developer?

It’s not mandatory, but it’s increasingly expected. Many companies use Docker for development environments, CI/CD pipelines, and deployment. Even if you work on a small project, knowing Docker helps you set up databases, message queues, or other services without installing them on your machine. It’s a valuable skill for any developer, especially in backend or DevOps roles.

How do I persist data in Docker?

Use volumes or bind mounts. A volume is a directory managed by Docker (e.g., docker volume create mydata), and you attach it with -v mydata:/var/lib/mysql. A bind mount maps a host directory into the container (e.g., -v /home/user/data:/data). Both survive container deletion. For databases, always use a volume so you don’t lose data when the container stops.

Is Docker safe for production?

Yes, when configured correctly. Production best practices include running as a non-root user, using read-only filesystems where possible, scanning images for vulnerabilities, and limiting resource usage with --memory and --cpus. Also, don’t run untrusted containers without proper isolation. Docker is widely used in production by major companies, but it requires the same security diligence as any other infrastructure.

Can I run Docker on Windows or macOS?

Yes. Docker Desktop provides a Linux VM under the hood to run Linux containers. On Windows, you can also run Windows containers, but they require Windows Server and are less common. Docker Desktop includes Kubernetes support and a GUI. For older or resource-limited machines, you can use Docker Engine inside a Linux VM or use Podman Desktop instead.