Interview's MateDocker
Interview's Mate

Docker

Compose · Networking · Security · Ops

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Docker topics
Lesson 79/ 160
04. Docker Networking

Network Segmentation for Frontend, Backend & Database Tiers

Segment frontend, backend, and database onto separate networks for least exposure.

IntermediateSegmentation · Tiers3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Design each network from an allowed caller/callee matrix and prove denied paths as well as successful ones.

Think of it like…

A building has a lobby, staff corridor and records room; one badged employee can cross, but visitors never receive a records-room key.

Where you’ve seen it

In practice, docker network create edge; docker network create backend --internal; docker network connect backend api is the concrete move for this job: segment frontend, backend, and database onto separate networks for least exposure. The release is not accepted until from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect confirms the result.

Words you’ll hear

Segmentation
The implementation control in docker network create edge; docker network create backend --internal; docker network connect backend api for segment frontend, backend, and database onto separate networks for least exposure.
Tiers
The result to observe with from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect, rather than infer from a successful command alone.
Least Exposure
The production boundary exposed when publishing postgres on 0.0.0.0 because the API had a route bug, or putting Traefik directly on the internal data network.

Visual diagram

Loading interactive diagram

Theory & deep dive

Segmentation control path

The concrete mechanism is docker network create edge; docker network create backend --internal; docker network connect backend api. The observable result is from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect; if those disagree, inspect the runtime evidence before changing unrelated settings.

Segment frontend, backend, and database onto separate networks for least exposure. Keep Segmentation, Tiers and Least Exposure in the same deployment record so the intent and the observed state cannot drift apart.

Concrete Segmentation setup

docker network create edge; docker network create backend --internal; docker network connect backend api

Key takeaway: Prove Tiers with from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect, not with command success alone.

Least Exposure failure boundary

Adding a firewall after connecting every service to one network produces a false sense of segmentation. A compromise of a multi-homed proxy is still powerful, so controls and patching on the crossing service matter. The narrow failure to design for is publishing postgres on 0.0.0.0 because the API had a route bug, or putting Traefik directly on the internal data network.

Accept this compromise explicitly: More tiers reduce blast radius but increase debugging and endpoint policy; a small app may begin with edge/backend and add data isolation later. The controlled check-from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect-also identifies the point where a different design is safer.

Deliberate failure test

Exercise this failure safely: publishing postgres on 0.0.0.0 because the API had a route bug, or putting Traefik directly on the internal data network.

Key takeaway: More tiers reduce blast radius but increase debugging and endpoint policy; a small app may begin with edge/backend and add data isolation later.

How it works, step by step

Step 1 of 4
Design

1. State the boundary

Write down why the workload needs this: Adding a firewall after connecting every service to one network produces a false sense of segmentation. A compromise of a multi-homed proxy is still powerful, so controls and patching on the crossing service matter.

Design each network from an allowed caller/callee matrix and prove denied paths as well as successful ones.
Key numbers at this step
Intent
Segmentation

When to use it & trade-offs

What it is

Place public ingress on an edge network, API/application components on a backend network and databases on a data network. The API becomes the narrow multi-homed path; direct host publishing and shared broad networks are removed.

Why it matters: Adding a firewall after connecting every service to one network produces a false sense of segmentation. A compromise of a multi-homed proxy is still powerful, so controls and patching on the crossing service matter.

When to reach for it

  • The fit is strongest for this job: segment frontend, backend, and database onto separate networks for least exposure. Pair it with from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect in the runbook.
  • Production Segmentation changes should make Tiers observable through docker network create edge; docker network create backend --internal; docker network connect backend api, rather than trusting the runtime default.
  • Keep a rollback example for the case where publishing postgres on 0.0.0.0 because the API had a route bug, or putting Traefik directly on the internal data network.

When to avoid or be careful

  • Do not accept command success while the system can still fail by publishing postgres on 0.0.0.0 because the API had a route bug, or putting Traefik directly on the internal data network.
  • Avoid erasing Least Exposure protection merely to dodge this cost: “More tiers reduce blast radius but increase debugging and endpoint policy; a small app may begin with edge/backend and add data isolation later”.
  • Do not replace the evidence path-from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect-with a screenshot or a mutable tag.

docker network create edge; docker network create backend --internal; docker network connect backend api: practical choices

Explicit Segmentation
Best for: Segment frontend, backend, and database onto separate networks for least exposure, with a reviewed runbook.

Strengths: Place public ingress on an edge network, API/application components on a backend network and databases on a data network. The API becomes the narrow multi-homed path; direct host publishing and shared broad networks are removed.

Watch out: More tiers reduce blast radius but increase debugging and endpoint policy; a small app may begin with edge/backend and add data isolation later.

Ambient default
Best for: Short-lived Tiers experiments with low blast radius.

Strengths: It can begin with docker network create edge; docker network create backend --internal; docker network connect backend api and fewer surrounding controls.

Watch out: It silently accepts publishing postgres on 0.0.0.0 because the API had a route bug, or putting Traefik directly on the internal data network, which makes the result hard to reproduce after promotion.

Managed Least Exposure
Best for: Teams that centralize Least Exposure policy across many workloads.

Strengths: Adding a firewall after connecting every service to one network produces a false sense of segmentation. A compromise of a multi-homed proxy is still powerful, so controls and patching on the crossing service matter.

Watch out: The platform adds an ownership and debugging layer; retain from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect as the direct check.

Interview signals & numbers to know

When this topic comes up

  • docker network create edge; docker network create backend --internal; docker network connect backend api
  • from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect
  • Failure signature: publishing postgres on 0.0.0.0 because the API had a route bug, or putting Traefik directly on the internal data network
  • Trade-off: More tiers reduce blast radius but increase debugging and endpoint policy; a small app may begin with edge/backend and add data isolation later.

Benchmarks & rules of thumb

3 trust zones -
edge, backend and data
1 allowed bridge service -
the API or proxy crossing tiers
0 public database ports -
desired in the segmented pattern

Common mistakes & follow-ups

Common interview mistakes

  • Treating a successful docker network create edge; docker network create backend --internal; docker network connect backend api as proof and skipping from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect.
  • Publishing postgres on 0.0.0.0 because the API had a route bug, or putting Traefik directly on the internal data network
  • Optimizing Segmentation without accepting that more tiers reduce blast radius but increase debugging and endpoint policy; a small app may begin with edge/backend and add data isolation later.

Likely interviewer follow-ups

  • Why does docker network create edge; docker network create backend --internal; docker network connect backend api address Segmentation here rather than through application code?
  • How would you distinguish healthy Tiers from the failure “publishing postgres on 0.0.0.0 because the API had a route bug, or putting Traefik directly on the internal data network” using from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect?
  • When would this trade-off-“More tiers reduce blast radius but increase debugging and endpoint policy; a small app may begin with edge/backend and add data isolation later”-justify a different Least Exposure design?
Interview tip: Give one concrete operation-docker network create edge; docker network create backend --internal; docker network connect backend api-and one proof-from the public proxy resolve only api on edge, and from a frontend container prove db cannot resolve or connect. Then name the boundary: publishing postgres on 0.0.0.0 because the API had a route bug, or putting Traefik directly on the internal data network.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Network Segmentation for Frontend, Backend & Database Tiers with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Packet Inspection & Traffic Troubleshooting inside Containers
Next topic
MTU Settings, DNS Configuration & Custom /etc/hosts Entries