docker exec mynginx ip addr show inside a running nginx container. What output will you see related to network interfaces?eth0 connected to a bridge network.Inside a Docker container, the network interface eth0 is created and assigned an IP from the Docker bridge network. The loopback lo is also present but wlan0 is not because containers do not share host Wi-Fi interfaces. The ip command is usually available in most base images or can be installed.
docker run -d -p 8080:80 nginx. What does this command do regarding container networking?-p flag maps host ports to container ports.The -p 8080:80 option maps port 8080 on the host machine to port 80 inside the container. This means you can access the nginx server by visiting localhost:8080 on the host.
The --net=none option disables all networking for the container, so it cannot reach the internet. User-defined bridge networks usually allow outbound traffic if configured correctly. The default bridge network allows outbound traffic by default. The --network host shares the host network and does not disable internet access.
web and db, on the same Docker user-defined bridge network named mynetwork. How can web container reach db by hostname?Docker user-defined bridge networks provide built-in DNS resolution, so containers can reach each other by container name as hostname. Using localhost refers to the container itself, not others. IP addresses can change, so hostnames are preferred. Host machine IP is not used for container-to-container communication on the same network.
Encrypted overlay networks or VPNs protect container traffic between hosts by encrypting data in transit. Exposing all ports increases attack surface. Disabling network isolation reduces security. Default bridge network does not provide encryption or isolation between hosts.