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 80/ 160
04. Docker Networking

MTU Settings, DNS Configuration & Custom /etc/hosts Entries

Tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups.

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

In plain words

Tune MTU from the path’s real overhead, set DNS resolvers at runtime for controlled environments and reserve extra_hosts for rare immutable aliases.

Think of it like…

MTU is bridge clearance for the largest truck, DNS is a directory and /etc/hosts is a handwritten sticky note.

Where you’ve seen it

In practice, docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test is the concrete move for this job: tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups. The release is not accepted until use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db confirms the result.

Words you’ll hear

MTU
The implementation control in docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test for tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups.
DNS Config
The result to observe with use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db, rather than infer from a successful command alone.
extra_hosts
The production boundary exposed when setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.

Visual diagram

Loading interactive diagram

Theory & deep dive

MTU control path

The concrete mechanism is docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test. The observable result is use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db; if those disagree, inspect the runtime evidence before changing unrelated settings.

Tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups. Keep MTU, DNS Config and extra_hosts in the same deployment record so the intent and the observed state cannot drift apart.

Concrete MTU setup

docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test

Key takeaway: Prove DNS Config with use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db, not with command success alone.

extra_hosts failure boundary

An MTU larger than the VPN/overlay path causes large requests to hang while ping still works. extra_hosts bypasses embedded DNS and becomes stale when a service moves; custom /etc/resolv.conf in an image loses platform-specific changes. The narrow failure to design for is setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.

Accept this compromise explicitly: Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking. The controlled check-use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db-also identifies the point where a different design is safer.

Deliberate failure test

Exercise this failure safely: setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.

Key takeaway: Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking.

How it works, step by step

Step 1 of 4
Design

1. State the boundary

Write down why the workload needs this: An MTU larger than the VPN/overlay path causes large requests to hang while ping still works. extra_hosts bypasses embedded DNS and becomes stale when a service moves; custom /etc/resolv.conf in an image loses platform-specific changes.

Tune MTU from the path’s real overhead, set DNS resolvers at runtime for controlled environments and reserve extra_hosts for rare immutable aliases.
Key numbers at this step
Intent
MTU

When to use it & trade-offs

What it is

MTU controls maximum packet/frame payload before fragmentation or tunneling. Docker can set network MTU and --dns values; extra_hosts writes a host-to-IP entry in container /etc/hosts. These mechanisms solve different problems and should not be mixed.

Why it matters: An MTU larger than the VPN/overlay path causes large requests to hang while ping still works. extra_hosts bypasses embedded DNS and becomes stale when a service moves; custom /etc/resolv.conf in an image loses platform-specific changes.

When to reach for it

  • The fit is strongest for this job: tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups. Pair it with use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db in the runbook.
  • Production MTU changes should make DNS Config observable through docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test, rather than trusting the runtime default.
  • Keep a rollback example for the case where setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.

When to avoid or be careful

  • Do not accept command success while the system can still fail by setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.
  • Avoid erasing extra_hosts protection merely to dodge this cost: “Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking”.
  • Do not replace the evidence path-use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db-with a screenshot or a mutable tag.

docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test: practical choices

Explicit MTU
Best for: Tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups, with a reviewed runbook.

Strengths: MTU controls maximum packet/frame payload before fragmentation or tunneling. Docker can set network MTU and --dns values; extra_hosts writes a host-to-IP entry in container /etc/hosts. These mechanisms solve different problems and should not be mixed.

Watch out: Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking.

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

Strengths: It can begin with docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test and fewer surrounding controls.

Watch out: It silently accepts setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it, which makes the result hard to reproduce after promotion.

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

Strengths: An MTU larger than the VPN/overlay path causes large requests to hang while ping still works. extra_hosts bypasses embedded DNS and becomes stale when a service moves; custom /etc/resolv.conf in an image loses platform-specific changes.

Watch out: The platform adds an ownership and debugging layer; retain use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db as the direct check.

Interview signals & numbers to know

When this topic comes up

  • docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test
  • use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db
  • Failure signature: setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it
  • Trade-off: Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking.

Benchmarks & rules of thumb

1450 bytes -
example overlay/VPN-safe MTU
28 bytes -
typical IPv4+ICMP overhead used in a do-not-fragment ping calculation
1.1.1.1 -
public DNS example, not necessarily an approved enterprise resolver

Common mistakes & follow-ups

Common interview mistakes

  • Treating a successful docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test as proof and skipping use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db.
  • Setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it
  • Optimizing MTU without accepting that path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking.

Likely interviewer follow-ups

  • Why does docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test address MTU here rather than through application code?
  • How would you distinguish healthy DNS Config from the failure “setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it” using use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db?
  • When would this trade-off-“Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking”-justify a different extra_hosts design?
Interview tip: Give one concrete operation-docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test-and one proof-use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db. Then name the boundary: setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply MTU Settings, DNS Configuration & Custom /etc/hosts Entries with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Network Segmentation for Frontend, Backend & Database Tiers
Next topic
Why Docker Compose? Declarative Multi-Container Orchestration