Source from Zeal Vora,KPLABS Course(Premium Instructor at Udemy)
Udemy
Zeal is one of my favorite author for docker. Please try to yourself π
(Tip: HE is ready to give some discount for students π)
Hi buddy, this is all are intermediate points. if you need to basic understanding please look at my previous docker beginner blog otherwise please ignore
-----------------Table of content-----------------
Networking
Type of networks in docker
Publish the argument
Legacy approach
Docker networking commands
- Networking
Communication between the container or securely make the communication so we using the networking.
- Container security
- Purpose of public and private containers
- Type of networks in docker
Based on microservice application need networking configuration was changed (private and public communication).
Docker0 interface is a default network card for docker.Inside of all network related activity based on docker0 virtual network card
- Bridge network
- User define bridge network
- Host network
- NAT network
- None network
- overlay
- macvlan
Bridge network
A bridge network uses a software bridge that allows containers connected to the same bridge network to communicate while providing isolation from containers which are not connected to that bridge network
- Bridge is default network for docker.Its easy to make the communication between inside and across the host.simply mention the diagram. its a two way communication
If we do not specify a driver, this is the type of network you are creating.
When you start Docker, a default bridge network (also called a bridge) is created automatically, and newly-started containers connect to it unless otherwise specified.
We also can create a User-Defined Bridge Network which is superior to the default bridge.
User define bridge network
User-defined bridges provide automatic DNS resolution between containers.
Containers on the default bridge network can only access each other by IP addresses, unless you use the --link option, which is considered legacy.
On a user-defined bridge network, containers can resolve each other by name or alias.
Host network
Connection establish the with-in the host its called host network.
NAT network(Network address translation)
It's kind of bridge network but one way transaction.some time database containers is a private network but update some necessary package via internet so in this case use this NAT.no one can ping the inside of container.
None network
If you want to completely disable the networking stack on a container, you can use the none network.
This mode will not configure any IP for the container and doesnβt have any access to the external network as well as for other containers.
3.Publish the argument
We were discussing an approach to publishing container port to host.
docker container run -dt --name webserver -p 80:80 nginx
This is also referred to as a publish list as it publishes the only a list of the port specified.
There is also a second approach to publish all the exposed ports of the container.
docker container run -dt --name webserver -P nginx
This is also referred to as a publish all.
In this approach, all exposed ports are published to random ports of the host.
4.Legacy approach
Before the Docker networks feature, you could use the Docker link feature to allow containers to discover each other and securely transfer information about one container to another container.
The --link flag is a legacy feature of Docker. It may eventually be removed. Unless you absolutely need to continue using it, we recommend that you use user-defined networks to facilitate communication between two containers instead of using --link
Docker networking commands
See the available docker network interface
docker network ls
See the available system network interface
ifconfig
Top comments (0)