Containernetzwerke konfigurieren
Erstellen und verwalten Sie benutzerdefinierte Docker-Netzwerke, um Ihre Services effektiv zu isolieren und zu verbinden.
Containernetzwerke konfigurieren ist eine kostenlose Docker & Kubernetes for Developers-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Docker & Kubernetes for Developers-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Docker & Kubernetes for Developers-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
Why Custom Docker Networks?
Docker provides default networks, but for complex applications, custom networks are key. They offer better isolation and controlled communication between your services.
Think of them as private virtual LANs just for your containers, giving you more control over how they interact.
Default Networks: Bridge, Host, None
When you run a container without specifying a network, it usually attaches to the bridge network by default. This allows containers to talk to each other and the host.
- Bridge: Default, isolated.
- Host: Container shares host's network stack.
- None: Isolated, no network access.
While useful, the default bridge network can be limiting for multi-service applications.
Crafting Your Own Network
To create a custom network, you use the docker network create command. The most common type is a bridge network, which acts like a virtual switch.
It provides better isolation and easier service discovery by name for containers connected to it.
docker network create my_app_networkRunning Containers on Custom Networks
You can connect a new container to a custom network right when you start it using the --network flag. This is the most common way to get your services talking from the start.
Containers on the same custom bridge network can communicate with each other using their container names as hostnames.
docker run -d --name web_server --network my_app_network nginx:latestDemo: Web Server on Custom Network
Let's create a custom network and run an Nginx web server on it. We'll publish port 8080 to access it from our host.
First, create the network, then run the container:
docker network create my_web_network
docker run -d --name my_nginx --network my_web_network -p 8080:80 nginx:latestConnecting Existing Containers
What if you have a container already running and want to connect it to a new custom network? You can use the docker network connect command.
This is useful when you want to dynamically add a container to a network without restarting it.
docker network connect my_app_network existing_container_nameDemo: Add to an Existing Network
Let's say you have a simple Alpine container running. We'll connect it to our previously created my_web_network to allow it to communicate with my_nginx.
First, run a container, then connect it:
docker run -d --name my_alpine alpine sleep 3600
docker network connect my_web_network my_alpinePeeking into Network Details
To understand what's happening inside your networks, use docker network inspect. This command shows detailed information, including connected containers and their IP addresses.
It's crucial for debugging network issues and verifying connections.
docker network inspect my_web_networkCleaning Up Your Networks
When containers are no longer needed on a network, you can disconnect them. When a network is no longer in use, it's good practice to remove it to keep your Docker environment tidy.
docker network disconnect [network] [container]docker network rm [network_name]
Remember to stop and remove all connected containers before removing a network.
docker network disconnect my_web_network my_alpine
docker network rm my_web_networkNetwork Configuration Quiz
Let's check your understanding of configuring Docker networks.
Recap: Custom Network Power
In this lesson, you learned how to create and manage custom Docker networks. These networks provide essential isolation and allow your containers to communicate securely by name.
- Used
docker network createto make custom networks. - Connected containers with
--networkordocker network connect. - Inspected networks using
docker network inspect. - Cleaned up with
docker network disconnectanddocker network rm.
Mastering custom networks is vital for building robust multi-container applications.
Lerne Docker & Kubernetes for Developers mit einem KI-Tutor — kostenlos
Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.
- Kurse
- 12
- Lektionen
- 48
Häufig gestellte Fragen
Ist die Lektion „Containernetzwerke konfigurieren“ kostenlos?
Ja — der vollständige Text von „Containernetzwerke konfigurieren“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Docker & Kubernetes for Developers-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Docker & Kubernetes for Developers-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Containernetzwerke konfigurieren“?
Erstellen und verwalten Sie benutzerdefinierte Docker-Netzwerke, um Ihre Services effektiv zu isolieren und zu verbinden. Du übst Docker & Kubernetes for Developers mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Docker & Kubernetes for Developers zu starten?
Keine Vorkenntnisse erforderlich. Docker & Kubernetes for Developers auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.
Wie lange dauert die Lektion „Containernetzwerke konfigurieren“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Docker & Kubernetes for Developers-Lektion Code schreiben und ausführen?
Ja. Jede Docker & Kubernetes for Developers-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Docker-Netzwerktypen verstehen
- Containernetzwerke konfigurieren
- Datenpersistenz mit Volumes
- Container mit Docker-Compose-Netzwerken verbinden