Back to Categories
DevOps / Infrastructure

DevOps / Infrastructure

Docker, GitHub Actions, CI/CD, AWS and monitoring

16Questions

🧠 Simple Definition (Word-for-word)

A Container is a lightweight, isolated software package containing an application and all its dependencies, sharing the host OS kernel. Docker simplifies containerization by providing portability, consistency, and resource efficiency. A Docker Image is an immutable, read-only blueprint template used to build containers, whereas a Docker Container is a runnable, live instance of an image. A Virtual Machine (VM) virtualizes hardware and runs a complete guest operating system, making it heavier and slower than a container.


⚡ Super Simple Line

Image = recipe (read-only blueprint).
Container = cake (running process sharing host OS kernel).
Virtual Machine = a separate house (heavy, virtualizes physical hardware and guest OS).


📊 Docker Container vs Virtual Machine

FeatureDocker ContainerVirtual Machine (VM)
ArchitectureShares host OS kernel (Process isolation)Full guest OS on Hypervisor (Hardware isolation)
Boot TimeSeconds (starts like a process)Minutes (boots full OS)
Resource SizeMBs (minimal overhead)GBs (includes full operating system)
PerformanceNear-native speedsSlower due to virtualization overhead

🛠️ Docker Advantages

  • Consistent Environments: Resolves the "works on my machine" problem by bundling the exact OS runtime, environment variables, and node modules together.

  • Resource Efficiency: You can run dozens of containers on a single host where you might only be able to run 3-4 full VMs.

  • Portability: Run the container on local Mac, staging Linux, or AWS ECS without code modifications.


⚡ One-line Interview Answer

Containers are lightweight processes sharing the host OS kernel, built from immutable read-only Docker images, and are more efficient than VMs which require full hardware virtualization and guest operating systems.

🧠 Simple Definition (Word-for-word)

Multi-stage: use multiple FROM instructions in one Dockerfile.


⚡ Super Simple Line

Build stage: install all dependencies and compile.


⚡ Key Details & Explanation

Multi-stage: use multiple FROM instructions in one Dockerfile. Build stage: install all dependencies and compile. Production stage: start fresh from a minimal base image (node:alpine), copy only the compiled artifacts from the build stage. Result: tiny production image that doesn't include dev dependencies, build tools, or source code — significantly smaller attack surface and faster pull times. Example: Next.js multi-stage build goes from ~1GB to ~150MB. In production, this matters because deployment and infrastructure decisions affect reliability. I would focus on safe rollout, clear monitoring, rollback options, and protecting secrets or user data.


⚡ One-line Interview Answer

Multi-stage: use multiple FROM instructions in one Dockerfile.

🧠 Simple Definition (Word-for-word)

Dockerizing a Next.js frontend and Node.js backend involves writing configurations to package them into containers. To optimize production container sizes, we use multi-stage Docker builds. A multi-stage build uses temporary container stages to compile code (e.g. typescript and asset bundling) and copies only the compiled runtime files into the final, lightweight production image, discarding development tools and node_modules.


⚡ Super Simple Line

Multi-stage Build = use a heavy image to build assets, then copy only the compiled static output to a tiny production image, shrinking size by up to 90%.


🧪 Optimized Multi-Stage Dockerfile for Next.js

# Stage 1: Build dependencies
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Stage 2: Production runner (tiny image)
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY package*.json ./
RUN npm ci --only=production
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public

EXPOSE 3000
CMD ["npm", "start"]

🔥 Key Dockerizing Best Practices

  • Use Alpine Images: node:20-alpine is much smaller than node:20 (approx. 50MB vs 900MB), reducing deployment download times.

  • Layer Caching Order: Always COPY package.json and run npm install before copying source files. This prevents rebuilding npm layers when source code changes.

  • Use .dockerignore: Exclude node_modules, .git, and build logs from being sent to the Docker context.


⚡ One-line Interview Answer

Next.js and Node apps are dockerized using multi-stage builds to compile assets in a build container, copying only production artifacts to Alpine-runner stages to minimize image size.

🧠 Simple Definition (Word-for-word)

Docker Compose is a tool for defining and running multi-container applications on a single host using a YAML configuration file. Kubernetes (K8s) is a production-grade container orchestration platform designed to manage containerized workloads across a cluster of multiple host nodes, providing automated scaling, rolling updates, self-healing, and service discovery.


⚡ Super Simple Line

Docker Compose = run multiple containers on 1 developer machine.
Kubernetes = run, scale, and load-balance containers across 100s of servers in production.


📊 Comparison Table

FeatureDocker ComposeKubernetes (K8s)
Target EnvironmentLocal development, small staging instancesProduction clusters, enterprise applications
ScalabilityManual (runs on a single machine)Auto-scaling based on CPU/memory usage
Self-HealingBasic restart policiesAdvanced checks (recreates failed containers automatically)
ComplexityLow (single YAML file, simple commands)High (learning curve, configuration manifests)

🧪 Typical Use Cases

  • Docker Compose: Spinning up a Next.js app, Express backend, and PostgreSQL database locally with a single docker-compose up command.

  • Kubernetes: Running a highly available e-commerce platform across multiple cloud availability zones, automatically adding database replicas during sale events.


⚡ One-line Interview Answer

Docker Compose is a local tool to coordinate multiple containers on a single host, while Kubernetes is a cluster orchestrator that automates scaling and self-healing in production environments.

🧠 Simple Definition (Word-for-word)

Typical Node.js/Next.js pipeline: trigger on push to main or PR.


⚡ Super Simple Line

Steps: (1) Checkout code, (2) Setup Node.js with cache for node_modules, (3) Install dependencies (npm ci), (4) Run linter (eslint), (5) Run tests (jest --coverage), (6) Build (next build or tsc), (7) Build Docker image and push to registry (on main only), (8) Deploy — trigger Vercel deploy or ssh to server and docker pull + restart.


⚡ Key Details & Explanation

Typical Node.js/Next.js pipeline: trigger on push to main or PR. Steps: (1) Checkout code, (2) Setup Node.js with cache for node_modules, (3) Install dependencies (npm ci), (4) Run linter (eslint), (5) Run tests (jest --coverage), (6) Build (next build or tsc), (7) Build Docker image and push to registry (on main only), (8) Deploy — trigger Vercel deploy or ssh to server and docker pull + restart. Use secrets for API keys. Use matrix strategy to test across Node versions. The value of testing is not only catching bugs, but giving the team confidence to refactor and deploy. The strongest tests usually cover business-critical paths, edge cases, and code that changes often. Example: Be specific about what you did at Standard Insights — the interviewer will probe.


⚡ One-line Interview Answer

Typical Node.js/Next.js pipeline: trigger on push to main or PR.

🧠 Simple Definition (Word-for-word)

Continuous Integration: developers merge code frequently, each merge triggers automated build + tests — catches integration bugs early.


⚡ Super Simple Line

Continuous Delivery: CI + automatically prepare a release candidate that is READY to deploy to production at any time — deployment is still a manual trigger.


⚡ Key Details & Explanation

Continuous Integration: developers merge code frequently, each merge triggers automated build + tests — catches integration bugs early. Continuous Delivery: CI + automatically prepare a release candidate that is READY to deploy to production at any time — deployment is still a manual trigger. Continuous Deployment: fully automated — every passing build is automatically deployed to production with no human approval. Most teams use CI + Continuous Delivery; full Continuous Deployment requires very high test confidence. In production, this matters because deployment and infrastructure decisions affect reliability. I would focus on safe rollout, clear monitoring, rollback options, and protecting secrets or user data.


⚡ One-line Interview Answer

Continuous Integration: developers merge code frequently, each merge triggers automated build + tests — catches integration bugs early.

🧠 Simple Definition (Word-for-word)

Blue-green: maintain two identical production environments (blue = current, green = new).


⚡ Super Simple Line

Deploy to green, test, then switch traffic from blue to green instantly.


⚡ Key Details & Explanation

Blue-green: maintain two identical production environments (blue = current, green = new). Deploy to green, test, then switch traffic from blue to green instantly. Rollback = switch back to blue. Zero downtime. Canary release: route a small percentage of traffic (1%, 5%) to the new version while the rest goes to the old version. Monitor error rates and metrics — gradually increase if healthy, rollback if not. More gradual risk management vs blue-green's binary switch. In production, this matters because deployment and infrastructure decisions affect reliability. I would focus on safe rollout, clear monitoring, rollback options, and protecting secrets or user data.


⚡ One-line Interview Answer

Blue-green: maintain two identical production environments (blue = current, green = new).

🧠 Simple Definition (Word-for-word)

S3 (Simple Storage Service): object storage — store files, images, backups, static site assets.


⚡ Super Simple Line

Buckets contain objects with keys.


⚡ Key Details & Explanation

S3 (Simple Storage Service): object storage — store files, images, backups, static site assets. Buckets contain objects with keys. Lifecycle policies auto-delete/archive old files. Presigned URLs allow secure client-side uploads directly to S3. EC2 (Elastic Compute Cloud): virtual machines — choose instance type (compute, memory, GPU optimized), run any software. EC2 = a server you manage. Lambda: serverless functions — run code in response to events (HTTP via API Gateway, S3 events, scheduled cron). No server management, pay per invocation, auto-scales, cold start latency. In production, this matters because deployment and infrastructure decisions affect reliability. I would focus on safe rollout, clear monitoring, rollback options, and protecting secrets or user data.


⚡ One-line Interview Answer

S3 (Simple Storage Service): object storage — store files, images, backups, static site assets.

🧠 Simple Definition (Word-for-word)

Vercel's edge network is a global CDN with compute capability at edge nodes.


⚡ Super Simple Line

ISR pages are generated and cached at the edge closest to the user.


⚡ Key Details & Explanation

Vercel's edge network is a global CDN with compute capability at edge nodes. ISR pages are generated and cached at the edge closest to the user. When the stale time expires, the edge node serves the stale page while triggering a background regeneration — the next request gets the fresh page. Edge Functions (Middleware, Edge API Routes) run at the edge node with very low latency but limited Node.js APIs (no fs, limited crypto). Edge runtime is great for geolocation, auth checks, A/B testing. In production, this matters because deployment and infrastructure decisions affect reliability. I would focus on safe rollout, clear monitoring, rollback options, and protecting secrets or user data.


⚡ One-line Interview Answer

Vercel's edge network is a global CDN with compute capability at edge nodes.

🧠 Simple Definition (Word-for-word)

Infrastructure metrics: CPU, memory, disk I/O, network throughput.


⚡ Super Simple Line

Application metrics: request rate, error rate, latency (p50, p95, p99 — percentiles matter more than averages), queue depth, cache hit rate.


⚡ Key Details & Explanation

Infrastructure metrics: CPU, memory, disk I/O, network throughput. Application metrics: request rate, error rate, latency (p50, p95, p99 — percentiles matter more than averages), queue depth, cache hit rate. Business metrics: active users, conversion funnel drop-offs. Tools: Datadog, New Relic, Grafana+Prometheus for infrastructure; Sentry for error tracking; LogRocket/FullStory for frontend sessions; Vercel Analytics for Core Web Vitals. Set alerts on p99 latency > threshold and error rate > baseline. In production, this matters because deployment and infrastructure decisions affect reliability. I would focus on safe rollout, clear monitoring, rollback options, and protecting secrets or user data.


⚡ One-line Interview Answer

Infrastructure metrics: CPU, memory, disk I/O, network throughput.

🧠 Simple Definition (Word-for-word)

Centralized logging: all services ship logs to a single platform (Datadog, Papertrail, AWS CloudWatch).


⚡ Super Simple Line

Simple querying across all services, single pane of glass, but single point of failure for logging.


⚡ Key Details & Explanation

Centralized logging: all services ship logs to a single platform (Datadog, Papertrail, AWS CloudWatch). Simple querying across all services, single pane of glass, but single point of failure for logging. Distributed logging: each service manages its own logs — problematic for tracing requests across services. For microservices: always centralize with structured logs (JSON), include a correlation/trace ID in every log line so you can trace a request across services. Use OpenTelemetry for distributed tracing. In production, this matters because deployment and infrastructure decisions affect reliability. I would focus on safe rollout, clear monitoring, rollback options, and protecting secrets or user data.


⚡ One-line Interview Answer

Centralized logging: all services ship logs to a single platform (Datadog, Papertrail, AWS CloudWatch).

🧠 Simple Definition (Word-for-word)

Health checks tell your platform whether an app instance should receive traffic or be restarted.


⚡ Super Simple Line

Readiness means the app is ready to serve requests now, for example DB connection established and migrations complete.


⚡ Key Details & Explanation

Health checks tell your platform whether an app instance should receive traffic or be restarted. Readiness means the app is ready to serve requests now, for example DB connection established and migrations complete. Liveness means the app process is still functioning and not deadlocked. If readiness fails, remove it from traffic; if liveness fails, restart it. This distinction matters in Kubernetes and any load-balanced environment. In production, this matters because deployment and infrastructure decisions affect reliability. I would focus on safe rollout, clear monitoring, rollback options, and protecting secrets or user data.


⚡ One-line Interview Answer

Health checks tell your platform whether an app instance should receive traffic or be restarted.

🧠 Simple Definition (Word-for-word)

Do not hardcode secrets in code or commit them to git.


⚡ Super Simple Line

Use environment variables or a secret manager such as AWS Secrets Manager, Parameter Store, Doppler, or Vault.


⚡ Key Details & Explanation

Do not hardcode secrets in code or commit them to git. Use environment variables or a secret manager such as AWS Secrets Manager, Parameter Store, Doppler, or Vault. Scope secrets per environment, rotate them, and give the minimum access needed. Also separate build-time and runtime variables carefully, especially in frontend frameworks like Next.js where public variables can be exposed to the browser. In production, this matters because deployment and infrastructure decisions affect reliability. I would focus on safe rollout, clear monitoring, rollback options, and protecting secrets or user data.


⚡ One-line Interview Answer

Do not hardcode secrets in code or commit them to git.

🧠 Simple Definition (Word-for-word)

Start with impact: error rate, latency, and which endpoints or users are affected.


⚡ Super Simple Line

Check recent deploys, logs, metrics, and whether a rollback is safer than debugging live.


⚡ Key Details & Explanation

Start with impact: error rate, latency, and which endpoints or users are affected. Check recent deploys, logs, metrics, and whether a rollback is safer than debugging live. Common fast checks: environment variables, DB connectivity, migration status, third-party outages, and whether only one instance or all instances are failing. Good incident handling is: stabilize first, then root-cause, then add prevention. In production, this matters because deployment and infrastructure decisions affect reliability. I would focus on safe rollout, clear monitoring, rollback options, and protecting secrets or user data.


⚡ One-line Interview Answer

Start with impact: error rate, latency, and which endpoints or users are affected.

🧠 Simple Definition (Word-for-word)

Data in Docker containers can be managed using volumes and bind mounts: Volumes: Volumes are the preferred way to persist data in Docker.


⚡ Super Simple Line

They are managed by Docker and can be easily created, shared, and backed up.


⚡ Key Details & Explanation

Data in Docker containers can be managed using volumes and bind mounts:

  1. Volumes: Volumes are the preferred way to persist data in Docker. They are managed by Docker and can be easily created, shared, and backed up. To create a volume, you can use the following command:
docker volume create my-volume

To use a volume in a container, you can specify it with the -v or --mount option when running the container:

docker run -d --name my-container -v my-volume:/data my-image

This command mounts the my-volume volume to the /data directory inside the container.

  1. Bind Mounts: Bind mounts allow you to mount a specific directory from the host machine into a container. This is useful for development purposes, as it allows you to share files between the host and the container. To use a bind mount, you can specify the host directory and the container directory with the -v option:

    docker run -d --name my-container -v /path/on/host:/data my-image
    

    This command mounts the /path/on/host directory from the host machine to the /data directory inside the container. By using volumes and bind mounts, you can effectively manage data in Docker containers, ensuring that important data persists even when containers are stopped or removed.


⚡ One-line Interview Answer

Data in Docker containers can be managed using volumes and bind mounts: Volumes: Volumes are the preferred way to persist data in Docker.

🧠 Simple Definition (Word-for-word)

docker build : Builds a Docker image from a Dockerfile.


⚡ Super Simple Line

docker run : Runs a Docker container from an image.


⚡ Key Details & Explanation

  • docker build: Builds a Docker image from a Dockerfile.
  • docker run: Runs a Docker container from an image.
  • docker ps: Lists running Docker containers.
  • docker stop: Stops a running Docker container.
  • docker rm: Removes a stopped Docker container.
  • docker images: Lists available Docker images on the local machine.
  • docker pull: Downloads a Docker image from a registry (e.g., Docker Hub).
  • docker push: Uploads a Docker image to a registry (e.g., Docker Hub).
  • docker-compose up: Starts and runs a multi-container application defined in a Docker Compose file.
  • docker-compose down: Stops and removes containers, networks, and volumes defined in a Docker Compose file.

⚡ One-line Interview Answer

docker build : Builds a Docker image from a Dockerfile.