Docker Networks :
There are three types of networks in docker.
- Bridge : Default network- private internal network created by docker on the host. All container attached to it by-default and they get an internal IP address usually in the range 172.17 series.
- none : containers are not attached to any network and does not have any access to external network or other container. They run in an isolated network.
- host : We can connect to host network by providing the ip and port of the host machine.
# Bridge Network:
docker run ubuntu
# none Network:
docker run ubuntu --network=none
# host Network:
docker run ubuntu --network=host
By default docker only create one internal bridge network. We can create our own internal network using the command Docker network create and specify the driver which is bridge.
# Create own network:
docker network create --driver bridge --subnet 182.10.0.0/51 custom-isolated-network-name
# list all network:
docker network ls
# How to see the network setting and IP Adress assigned to an existing container:
docker inspect container-name
# Network => bridge