Which Docker network driver provides complete isolation between containers, preventing them from communicating unless explicitly connected?
Think about a network driver that disables all networking for containers.
The none network driver disables all networking for the container, isolating it completely. Other drivers like bridge allow communication within the network, host shares the host network, and overlay is for multi-host networking.
What is the output of the command docker network ls after creating a user-defined bridge network named isolated_net?
docker network create isolated_net docker network ls
Look for the user-defined network with the correct driver and scope.
When you create a user-defined bridge network, it appears in the list with the bridge driver and local scope. The default networks bridge, host, and none also appear.
You want to run two services, web and db, in Docker Compose. The web service should not communicate with db. Which network configuration achieves this isolation?
version: '3.8'
services:
web:
image: nginx
networks:
- webnet
db:
image: mysql
networks:
- dbnet
networks:
webnet:
dbnet:Think about how Docker Compose networks control communication between services.
Assigning each service to a separate network isolates them because containers can only communicate if they share a network. Sharing the same network allows communication.
You have two containers connected to the same user-defined bridge network but they cannot ping each other. What is the most likely cause?
Consider network scope and physical host location.
User-defined bridge networks are local to a single Docker host. Containers on different hosts cannot communicate over this network unless using overlay networks or other multi-host solutions.
In a multi-service Docker application, what is the best practice to ensure secure network isolation between services that should not communicate?
Think about how Docker networks control communication and isolation.
Creating separate user-defined bridge networks and connecting services only to the networks they need limits communication to only those services. The default bridge network is shared and less secure. The host network driver shares the host network and does not isolate. Overlay networks are for multi-host but require additional configuration.