Interview Prep/Docker/Networking and Compose

You need a fixed IP for a container.

IntermediateScenarioNetworking and Compose
Answer

Situation read → Some legacy firewalls or configs require static IPs.

What I'd do →

docker network create --subnet 172.30.0.0/24 fixed
docker run --network fixed --ip 172.30.0.10 myapp

In Compose, set ipam config and ipv4_address.

Why → Static IPs only work on user-defined networks with a subnet.

Interview tip → Prefer DNS names; static IPs signal tight coupling.

All Docker questions Roadmap: Docker & containers

More on Networking and Compose