0Pricing
Docker & Kubernetes for Developers · Aula

Entendendo os tipos de rede do Docker

Examine diferentes drivers de rede do Docker, como bridge, host e overlay, e seus casos de uso na comunicação entre contêineres.

Entendendo os tipos de rede do Docker é uma aula grátis de Docker & Kubernetes for Developers no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Docker & Kubernetes for Developers, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Docker & Kubernetes for Developers inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Intro to Docker Networks

Welcome to Docker networking! Containers need to talk to each other and the outside world. Docker networks make this possible.

Understanding network types is key to building robust and scalable applications. Let's dive in!

The Default Bridge Network

When you first install Docker, it creates a default bridge network named bridge. Unless specified, all new containers connect to this network.

  • Containers on the same default bridge can communicate via IP address.
  • They are isolated from the host machine's network.

Inspecting Default Bridge

You can see the default bridge network and its details using Docker commands. Try running these:

docker network ls
docker network inspect bridge

Custom Bridge Networks

While the default bridge works, custom bridge networks offer significant advantages:

  • Isolation: Better segmentation for different applications.
  • DNS Resolution: Containers can communicate by name, not just IP.
  • Portability: Easier to manage complex setups.

Creating a Custom Bridge Network

Let's create our own custom bridge network. This network will be isolated and provide DNS resolution for containers connected to it.

docker network create my-custom-app-net

Connect Containers to Custom Network

Now, let's run two containers on our my-custom-app-net and see them talk to each other using their names. This is a huge benefit!

docker run -d --name web1 --network my-custom-app-net nginx
docker run -it --rm --network my-custom-app-net alpine ping -c 2 web1

The 'Host' Network Driver

The host network driver is different. It removes network isolation between the container and the Docker host.

A container using the host network shares the host's network stack directly. This means:

  • No port mapping is needed.
  • The container uses the host's IP address.

Host Network Use Cases

The host network can be useful for specific scenarios:

  • Performance: Minimizes networking overhead.
  • Monitoring: Accessing host-level network interfaces directly.

However, it reduces isolation and can lead to port conflicts if not managed carefully.

docker run -it --rm --network host alpine sh

Overlay Networks for Swarm

When you start dealing with multiple Docker hosts (machines), you need a way for containers on different hosts to communicate. This is where overlay networks come in.

Overlay networks are crucial for Docker Swarm, allowing services to communicate seamlessly across an entire cluster.

Overlay Network Advantages

Overlay networks provide:

  • Multi-host communication: Containers on different physical machines can talk.
  • Service Discovery: Integrated DNS for services across the swarm.
  • Load Balancing: Distributes traffic among service replicas.

They abstract away the underlying physical network complexity.

Network Type Quiz

Test your knowledge of Docker network types!

Network Types Recap

Great job! You've learned about the main Docker network types:

  • Bridge (Default & Custom): For single-host container communication. Custom bridges add isolation and DNS.
  • Host: For containers that need direct access to the host's network stack.
  • Overlay: For multi-host container communication in a Docker Swarm.

Choosing the right network type is vital for your application's architecture. Next, we'll learn how to configure them!

Perguntas Frequentes

A aula “Entendendo os tipos de rede do Docker” é grátis?

Sim — o texto completo de “Entendendo os tipos de rede do Docker” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Docker & Kubernetes for Developers, atualize para CoddyKit PRO. O curso de Docker & Kubernetes for Developers inclui 4 aulas no total.

O que vou aprender em “Entendendo os tipos de rede do Docker”?

Examine diferentes drivers de rede do Docker, como bridge, host e overlay, e seus casos de uso na comunicação entre contêineres. Você pratica Docker & Kubernetes for Developers com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Docker & Kubernetes for Developers?

Nenhuma experiência prévia é necessária. Docker & Kubernetes for Developers no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “Entendendo os tipos de rede do Docker”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Docker & Kubernetes for Developers?

Sim. Cada aula de Docker & Kubernetes for Developers inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Entendendo os tipos de rede do Docker
  2. Configuração de redes de contêineres
  3. Persistência de dados com volumes
  4. Conectando contêineres com redes do Docker Compose
← Voltar para Docker & Kubernetes for Developers