Docker Networking Tutorial | Docker Documentation
Docker Networking Tutorial | Docker Documentation
Docker container is a powerful system and what makes it even more powerful is its networking system. You can connect docker to one another, or even we can connect docker to other work loads too.
There are different types of network/network drivers which make the docker powerful system.
- Bridge
- Host
- Overlay
- Macvlan
Bridge Network:
The default network driver. In the event that you don't determine a driver, this is the kind of network you are making. Bridge networks are generally utilized when your applications run in independent containers that need to be conveyed.
Host Network
For independent containers, eliminate network seclusion between the holder and the Docker host, and utilize the host's networking straightforwardly. host is just accessible for swarm administrations on Docker 17.06 and higher.
Overlay Network
Overlay networks interface different Docker daemons together and empower swarm administrations to speak with one another. You can likewise utilize overlay organizations to encourage correspondence between a swarm administration and an independent container, or between two standalone containers on various Docker daemons. This system eliminates the need to do OS-level directing between these container.
Macvlan Network
Macvlan networks permit you to dole out a MAC address to a container, causing it to show up as a physical device on your organization. The Docker daemon courses traffic to containers by their MAC addresses. Utilizing the macvlan driver is in some cases the most ideal decision when managing inheritance applications that hope to be legitimately associated with the physical organization, instead of steered through the Docker host's organization stack.
Docker Networking Commands
docker network ls : This will show you the networks your system has or are in use.
docker network inspect {name of network} : This command will help you to inspect the desired network configurations.
docker network create {name} : This will let you create a new network of your own choice.
launch the docker container in desired network
sudo docker run --network app --name nginx-live --restart=always -v /usr/share/nginx/html/:/usr/share/nginx/html/ -p 80:80 -p 443:443 -d nginx:latest
by using the above command, we can launch the container in desired network.