docker network ls after creating two networks and connecting a container to both?net1 and net2. Then you run a container mycontainer connected to net1. Finally, you connect mycontainer to net2 using docker network connect. What will docker network ls show regarding these networks?docker network create net1 docker network create net2 docker run -dit --name mycontainer --network net1 alpine sh docker network connect net2 mycontainer docker network ls
The docker network ls command lists all existing networks regardless of container connections. Creating two networks and connecting a container to both does not remove or hide any network. Both net1 and net2 will appear in the list.
webapp. You want to connect it to two networks: frontend and backend. Which sequence of commands will achieve this?You must create the networks first before connecting a container to them. The docker network connect command connects an existing container to an existing network. The correct sequence creates both networks first, then connects the container to each.
docker network connect mynet mycontainer but get the error: container is already connected to network mynet. What is the most likely cause?This error means the container is already connected to the specified network. Docker prevents duplicate connections to the same network for a container.
netA and netB. How does this affect the container's network interfaces and communication?Docker assigns a separate network interface inside the container for each connected network. This allows the container to communicate on all connected networks independently.
Using user-defined bridge networks allows better control, isolation, and naming clarity. Connecting containers only to networks they need reduces attack surface and complexity.