Skip to content

Docker: Docker Networks

Rayan edited this page Mar 19, 2024 · 16 revisions

Docker Networks

Everything to docker networks and more. You'll find it all here.

Definition

Docker Networks what are they? Very-Simple, imagine them as a bridge between containers and the external environment. It allows traffic to travel between the containers (internal environment) to external systems (external environment). This is done by offering various networking models and configurations, Docker Networks empower developers to design flexible, scalable and secure network architecture for their containerized applications. It helps with restricting access to some container services.

Use Cases

Docker Networks offer versatile solutions for containerized environments, allowing seamless communication and connectivity. Let's delve into some prominent use cases where Docker Networks play a crucial role:

  1. Microservices Architecture: Docker Networks enable communication between microservices in containerized applications, supporting scalability and fault isolation.

  2. Multi-Tier Applications: Docker Networks facilitate the deployment of multi-tier applications by connecting frontend, backend, and database containers, ensuring secure and efficient communication.

  3. Hybrid Cloud Deployments: Docker Networks allow for seamless communication between containers across on-premises and cloud environments, enabling organizations to leverage both infrastructures effectively.

Docker Networks provide indispensable capabilities for a variety of use cases, including microservices architecture, multi-tier applications, and hybrid cloud deployments. By enabling efficient communication and connectivity between containers.

Docker Network Types

If you ever created a docker network over Portainer you may have noticed that there are multiple network types you could use to configure your own customized docker network. Then you also may have realized that they aren't really types but more akin to divers for the docker network. There a five different drivers, these drivers are the following:

  1. bridge
  2. host
  3. overlay
  4. ipvlan
  5. macvlan
  6. none

The effects on the docker network depend on the driver used, each driver has a different effect. See below for more information:

  1. bridge: When using the bridge driver the docker network will use the default network driver, meaning it'll have access to the internet of the hosts driver. It uses NAT for this, to create a distinct network from the host.
  2. host: When using the host driver the docker network will remove the isolation between host and container network, meaning it will directly use the network interface. Meaning that they wont have their own dedicated network stack and ip-address'.
  3. overlay: When using the overlay driver for the docker network the containers within the docker networks are most likely operating on docker swarm, cloud or different hosts/nodes. The overlay driver allows to have interconnectivity between multiple nodes, by allowing the daemons to communicate with each other.
  4. ipvlan: When using the ipvlan driver in Docker, the Docker network leverages the physical or virtual interfaces of the host directly. This unique approach offers enhanced performance compared to other network drivers, as it circumvents the overhead associated with virtual bridges. Additionally, it grants administrators full control over IPv4 and IPv6 configurations.
  5. macvlan: When using the macvlan driver in Docker, containers are indeed assigned MAC addresses that are distinct from the host's MAC address. These MAC addresses are typically associated with the containers' virtual network interfaces, which are created by the macvlan driver.
  6. none: When using the none driver or simply said no driver it will completely isolate the docker containers contained in the docker network from the outside world (Outside world being external environment e.g. Host and other docker networks and nodes)

Basic Docker Networks Setup

Advanced Docker Networks Setup