فهم أنواع شبكات Docker
افحصوا برامج تشغيل شبكات Docker المختلفة، مثل bridge وhost وoverlay، وحالات استخدامها للاتصال بين الحاويات.
فهم أنواع شبكات Docker درس مجاني في Docker & Kubernetes for Developers على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Docker & Kubernetes for Developers، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Docker & Kubernetes for Developers 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
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 bridgeCustom 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-netConnect 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 web1The '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 shOverlay 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!
الأسئلة الشائعة
هل درس «فهم أنواع شبكات Docker» مجاني؟
نعم — نص درس «فهم أنواع شبكات Docker» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Docker & Kubernetes for Developers، انتقل إلى CoddyKit PRO. تتضمن دورة Docker & Kubernetes for Developers 4 دروس في المجموع.
ماذا ستتعلم في «فهم أنواع شبكات Docker»؟
افحصوا برامج تشغيل شبكات Docker المختلفة، مثل bridge وhost وoverlay، وحالات استخدامها للاتصال بين الحاويات. تتمرن على Docker & Kubernetes for Developers مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Docker & Kubernetes for Developers؟
لا تُشترط خبرة سابقة. Docker & Kubernetes for Developers على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «فهم أنواع شبكات Docker»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Docker & Kubernetes for Developers هذا؟
نعم. كل درس في Docker & Kubernetes for Developers يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- فهم أنواع شبكات Docker
- تهيئة شبكات الحاويات
- استمرارية البيانات باستخدام وحدات التخزين
- ربط الحاويات بشبكات Docker Compose