Networking (15%) Flashcards
Networking (15%)
What is the default network that the docker creates automatically?
Bridge
How to list the networks on the Docker machine?
docker netwrok ls
How to connect to the default bridge network when you create a container?
// since no network is specified, it will be connected to default bridge network
docker run -dit –name alpine1 alpine ash
How to inspect the default network bridge?
docker network inspect bridge
The default bridge network is not recommended for production. Is this statement correct?
Yes
How to create a user-defined network?
docker network create –driver bridge my-network
How to inspect the user-defined network?
docker network inspect my-network
How to connect to the user-defined network while creating a container?
docker run -dit –name alpine1 –network my-network alpine ash
How to connect the existing container to the user-defined network?
docker netwrok connect my-network alpine2
How to troubleshoot a user-defined network?
// using nicolaka/netshootdocker run -it --rm --network container: nicolaka/netshoot
How to publish a port so that it can be accessed externally?
docker run -p 127.0.0.1:$HOSTPORT:$CONTAINERPORT –name CONTAINER -t
How to list port mappings or a specific mapping for the container?
// List the containers docker ps
// use this command with container name docker port
// USE the specific port docker port
What are all the different built-in network drivers?
Bridge Network Driver Overlay Network Driver MACVLAN Driver Host None
What are the Bridge network and its use case?
The bridge driver creates a private network internal to the host so containers on this network can communicate.The bridge driver does the service discovery for us automatically if two containers are on the same networkThe bridge driver is a local scope driver, which means it only provides service discovery, IPAM, and connectivity on a single host.
What is the scope of the bridge network?
local