02 / 08

What can I use Docker for?

We can use Docker to fundamentally change how you build, test, and deploy your applications. Docker streamlines the development lifecycle by allowing developers to work in standardized environments using local containers which provide your applications and services. Containers are great for continuous integration and continuous delivery (CI/CD) workflows.

Local Development 'On-Demand'
  1. 1

    Instead of installing different versions of Node.js, MongoDB, or Redis directly on your machine (and cluttering your OS), you use Docker to spin them up only when needed.

  2. 2

    Version Management: Run a legacy project on Node 14 and a new one on Node 22 simultaneously without nvm conflicts.

  3. 3

    Infrastructure-as-Code: Use a docker-compose.yml file to define your entire stack (Node API + React Frontend + MongoDB + Mongo Express). A new developer can join your team and start the entire environment with one command: docker compose up.

Standardizing Your CI/CD Pipelines, Docker becomes your 'Environment Wrapper'.
  1. 1

    Headless Testing: Use an official Cypress Docker image (like cypress/included) to run your end-to-end tests in a container during your GitHub Actions workflow. This ensures that the browser version and OS dependencies are identical to what you tested locally.

  2. 2

    Build Artifacts: Instead of uploading a folder of code to a server, you build a Docker Image. This image is a finished 'package' that includes your code and its exact environment. You push this to a registry (like Amazon ECR) and deploy it to AWS.

Microservices & Scaling
  1. 1

    If you are moving away from monolithic apps, Docker is the industry standard for microservices.

  2. 2

    Isolation: You can update the Node.js version of your 'Auth Service' without affecting your 'Payment Service.'

  3. 3

    Scaling: In production (using AWS ECS or App Runner), you can instantly tell AWS to 'run 5 more copies of this container' to handle a spike in traffic.

Efficient Production Deployments
  1. 1

    In 2026, 'Lift and Shift' migrations are being replaced by Cloud-Native deployments.

  2. 2

    Multi-Stage Builds: You can use Docker to build your React app in a heavy 'Node' environment, then discard the Node tools and only copy the final build files into a tiny, secure Nginx container for production. This reduces your image size from ~900MB to ~20MB, saving on cloud storage and improving deployment speed.

  3. 3

    Blue-Green Deployments: You can spin up a new version of your container alongside the old one, test it, and then switch the traffic over with zero downtime.

Difficulty: 2/10
Topics: containerization, images, orchestration

Scenario Questions

0-2 years experience
  1. 1

    How would you write a Dockerfile to containerize a simple Python Flask application?

  2. 2

    What happens if you run docker run without a -v flag but your app writes to a local file?

  3. 3

    You need to run a PostgreSQL container for local development. How do you persist data across container restarts?

2-5 years experience
  1. 1

    Your docker-compose file spins up a web service and a Redis cache. The web service can't connect to Redis by hostname. What's likely missing?

  2. 2

    A container passes all tests locally but fails in CI with a 'permission denied' error on a mounted volume. Walk me through how you'd debug this.

  3. 3

    The team wants to shrink a 1.2 GB Node.js image. What multi-stage build techniques would you apply, and what's the tradeoff?

5-8 years experience
  1. 1

    Design a multi-stage Dockerfile for a Go microservice that produces a distroless production image under 20 MB. What build-time vs runtime dependencies do you separate?

  2. 2

    Production containers are taking 30+ seconds to become healthy after deploy. What Docker-layer and runtime knobs would you tune?

  3. 3

    You're implementing blue-green deployments with Docker Swarm. How do you handle session affinity and rolling updates without downtime?

8+ years experience
  1. 1

    The organization is moving 200 legacy Java apps from VMs to containers. Many require OS-level packages and kernel modules. What's your migration strategy for the uncontainerizable ones?

  2. 2

    How do you enforce image signing, vulnerability scanning, and base-image freshness across 50 independent teams without blocking deployments?

  3. 3

    Leadership asks whether to standardize on Docker Engine or switch to Podman for rootless containers. What technical and organizational factors decide this?

Follow-up Questions

  • How does Docker differ from a virtual machine?
  • What are scenarios where you would avoid using Docker?
  • Explain the difference between an image and a container.