- same as the virtual machine networking here are seven types of network present
- bridge - laptop ke andar ek local address use karega like laptop is router for it
- host - laptop ka ip use karega
- macvlan - make a separate machine direct router se connect hoga making it more usefull for hacking it will have it's own macaddress
- ipvlan - more control over ip address assign ip to daemon according to given ip poll
- overlay -- multiple daemon ko sath me lata hai
- none - isolate the machine
docker run -it --name server1 weibeld/ubuntu-networking
ping google.com
ipconfig for windows for linux/mac ifconfig
docker network ls
docker inspect bridge
- create another ubuntu container
docker run -it --name server2 weibeld/ubuntu-networking - To know ip address use
hostname -I
ping [ipaddress]
docker network
dokcer network ls
docker network create work
docker run -it --network work --name server3 weibeld/ubuntu-networking
hostname -I
both server 1[172.17.0.2] and server 3 has different ip like[172.18.0.2]
since the server1 and server3 are on the different class of network or on the different bridge you cannot ping to one another
- we can not ping a container by it's name because they are on the default network
docker network connect work server1
now server1 will have 2 ip address and connected to default bridge as well as our work network
ping server1 or it's work ip address
docker start server3
docker exec -it server3 bash
so our docker is connect through a bridge to our machine so when we want to run any web application on the specific port like 3000 we have to do port-forwarding so that our machine can access the daemon's port
docker run -it --network host server2