Fatskills
Practice. Master. Repeat.
Study Guide: Docker Docker Networking Default Bridge Network vs UserDefined Bridge Automatic DNS Resolution
Source: https://www.fatskills.com/kubernetes/chapter/docker-docker-networking-default-bridge-network-vs-userdefined-bridge-automatic-dns-resolution

Docker Docker Networking Default Bridge Network vs UserDefined Bridge Automatic DNS Resolution

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~3 min read

1. Core Command / Concept

Create a user-defined bridge network with automatic DNS resolution to isolate and manage containers. docker network create

2. Step-by-Step

  1. Check the default bridge network: docker network ls
    Output: A list of networks, including the default bridge network.
  2. Create a user-defined bridge network: docker network create my-bridge
    Output: A message indicating the network was created.
  3. List networks again to verify the new network: docker network ls
    Output: The new network should be listed.
  4. ⚠️ Delete the network: docker network rm my-bridge
    Output: A message indicating the network was removed.

3. Real Commands with Examples

  1. Purpose: Create a user-defined bridge network with automatic DNS resolution.
    Command: docker network create --driver bridge --subnet 192.168.1.0/24 --gateway 192.168.1.1 my-bridge
    Flags:
    • --driver bridge: Use the bridge network driver.
    • --subnet 192.168.1.0/24: Set the subnet for the network.
    • --gateway 192.168.1.1: Set the gateway for the network.
  2. Purpose: Create a user-defined bridge network with automatic DNS resolution and a specific IP address for a container.
    Command: docker network create --driver bridge --subnet 192.168.1.0/24 --gateway 192.168.1.1 --ip-range 192.168.1.0/24 my-bridge
    Flags:
    • --ip-range 192.168.1.0/24: Set the IP range for the network.
  3. Purpose: Create a user-defined bridge network with automatic DNS resolution and a specific IP address for a container, and enable IPAM.
    Command: docker network create --driver bridge --subnet 192.168.1.0/24 --gateway 192.168.1.1 --ip-range 192.168.1.0/24 --ipam-driver default my-bridge
    Flags:
    • --ipam-driver default: Enable IPAM.

4. Common Errors

  1. Error message: "Error response from daemon: failed to create endpoint: network not found"
    Why it happens: The network was deleted or does not exist.
    One-line fix: docker network create my-bridge
  2. Error message: "Error response from daemon: failed to create endpoint: failed to create network: network with name 'my-bridge' already exists"
    Why it happens: The network already exists.
    One-line fix: docker network rm my-bridge and then docker network create my-bridge
  3. Error message: "Error response from daemon: failed to create endpoint: failed to create network: network with name 'my-bridge' has an invalid configuration"
    Why it happens: The network configuration is invalid.
    One-line fix: Check the network configuration and correct any errors.

5. Quick Checks

  1. Situation: A container is not resolving DNS.
    Command to run: docker network inspect my-bridge
    What a correct response looks like: The network configuration should include DNS settings.
  2. Situation: A network is not listed.
    Command to run: docker network ls
    What a correct response looks like: The network should be listed.
  3. Situation: A network is not deleted.
    Command to run: docker network rm my-bridge
    What a correct response looks like: The network should be deleted.

6. Last-Minute Reference

• The default bridge network is named "bridge".
• The default subnet for the default bridge network is 172.17.0.0/16.
• The default gateway for the default bridge network is 172.17.0.1.
• The default IP range for the default bridge network is 172.17.0.0/16.
• The default IPAM driver for the default bridge network is "default".
• ⚠️ The docker network create command will overwrite an existing network with the same name.
• ⚠️ The docker network rm command will delete all containers attached to the network.
• ⚠️ The docker network inspect command will display detailed information about the network.
• The docker network ls command will list all networks.
• The docker network create command will create a new network.




ADVERTISEMENT