====== Docker - Networking - Docker Network Drivers ======
Docker offers multiple network drivers, each suited for different use cases.
----
===== Bridge Networks =====
* Default network type for standalone containers.
* Containers on the same bridge network can communicate using IP addresses or container names.
* Suitable for applications running on a single host.
Create a new bridge network:
docker network create my-bridge-network
----
===== Host Networks =====
* Containers share the host's network stack.
* No network isolation between the container and the host.
* Offers performance benefits by reducing network overhead.
Run a container using the host network:
docker run --network host my-image
----
===== Overlay Networks =====
* Used for swarm services and multi-host networking.
* Enables containers running on different Docker hosts to communicate securely.
* Requires a key-value store like Consul or etcd for coordination.
Create an overlay network:
docker network create -d overlay my-overlay-network
----
===== Macvlan Networks =====
* Assigns a MAC address to each container, making it appear as a physical device on the network.
* Containers can be directly connected to the physical network.
* Useful for legacy applications requiring direct network access.
Create a macvlan network:
docker network create -d macvlan \
--subnet=192.168.1.0/24 \
--gateway=192.168.1.1 \
-o parent=eth0 my-macvlan-network
----