A custom network is a user-defined network that allows Docker containers to communicate securely and efficiently, separate from the default networks.
Click to reveal answer
beginner
Why should you use custom networks instead of the default bridge network?
Custom networks provide better isolation, control over container communication, and easier service discovery compared to the default bridge network.
Click to reveal answer
intermediate
How do custom networks improve security in Docker?
They limit which containers can talk to each other by isolating groups of containers, reducing the risk of unwanted access.
Click to reveal answer
beginner
What command creates a custom Docker network?
docker network create
Click to reveal answer
intermediate
How does using custom networks help with service discovery?
Containers on the same custom network can find each other by container name, making it easier to connect services without using IP addresses.
Click to reveal answer
What is the main benefit of using a custom Docker network?
AMore CPU resources for containers
BFaster container startup time
CAutomatic container updates
DBetter container communication and isolation
✗ Incorrect
Custom networks improve how containers communicate and isolate them from others.
Which command creates a new custom Docker network?
Adocker create network my-network
Bdocker network create my-network
Cdocker network new my-network
Ddocker create my-network network
✗ Incorrect
The correct syntax is 'docker network create '.
How do containers on a custom network find each other?
ABy MAC address
BBy IP address only
CBy container name
DBy host machine name
✗ Incorrect
Containers can use container names for easy service discovery on custom networks.
What is a security advantage of custom Docker networks?
AThey isolate containers to limit unwanted communication
BThey encrypt all container data automatically
CThey prevent containers from using CPU
DThey disable container logging
✗ Incorrect
Custom networks isolate containers, reducing risk of unauthorized access.
Which Docker network is used by default if no custom network is specified?
Abridge
Bhost
Cnone
Doverlay
✗ Incorrect
The default Docker network is called 'bridge'.
Explain why using custom Docker networks is important for container communication and security.
Think about how containers talk to each other and how to keep them safe.
You got /4 concepts.
Describe the steps to create and use a custom Docker network for your containers.
Start with creating the network, then connect containers to it.
You got /4 concepts.
Practice
(1/5)
1. Why is it important to create a custom Docker network instead of using the default network?
easy
A. It allows containers to communicate securely and isolate traffic.
B. It automatically increases container CPU usage.
C. It disables container communication completely.
D. It removes the need for container images.
Solution
Step 1: Understand default network limitations
The default Docker network allows basic communication but lacks isolation and security controls.
Step 2: Benefits of custom networks
Custom networks let you isolate containers and control which containers can talk to each other securely.
Final Answer:
It allows containers to communicate securely and isolate traffic. -> Option A
Quick Check:
Custom networks improve security and isolation = B [OK]
Hint: Custom networks isolate and secure container communication [OK]
Common Mistakes:
Thinking default network is always secure
Believing custom networks increase CPU usage
Assuming custom networks disable communication
2. Which command correctly creates a new custom Docker network named my-net?
easy
A. docker network create my-net
B. docker create network my-net
C. docker network new my-net
D. docker net create my-net
Solution
Step 1: Recall Docker network creation syntax
The correct command to create a network is docker network create <name>.
Step 2: Check each option
Only docker network create my-net matches the correct syntax exactly.
Final Answer:
docker network create my-net -> Option A
Quick Check:
Correct command syntax = D [OK]
Hint: Use 'docker network create' to make custom networks [OK]
Common Mistakes:
Swapping 'create' and 'network' order
Using 'new' instead of 'create'
Shortening 'network' to 'net' incorrectly
3. Given this Docker command sequence:
docker network create app-net
docker run -d --name web --network app-net nginx
docker run -d --name db --network app-net mysql
What will happen if the web container tries to connect to db using the container name?
medium
A. The connection will fail because containers need IP addresses.
B. The connection will succeed because both containers share the custom network.
C. The connection will fail because default network is required.
D. The connection will succeed only if ports are exposed.
Solution
Step 1: Understand container networking on custom networks
Containers on the same custom network can reach each other by container name as DNS resolves names automatically.
Step 2: Analyze the command setup
Both web and db are on app-net, so web can connect to db using its name.
Final Answer:
The connection will succeed because both containers share the custom network. -> Option B
Quick Check:
Same custom network enables name-based communication = A [OK]
Hint: Containers on same custom network communicate by name [OK]
Common Mistakes:
Thinking IP addresses are always needed
Assuming default network is required for name resolution
Believing ports must be exposed for internal communication
4. You created a custom network with docker network create my-net and started two containers attached to it. But they cannot communicate by container name. What is the most likely cause?
medium
A. Docker daemon is not running.
B. The network was created with the wrong driver.
C. Containers need to be restarted twice.
D. Containers were started without specifying the network.
Solution
Step 1: Check container network attachment
Containers must be started with --network my-net to join the custom network.
Step 2: Identify common mistake
If containers are not attached to the custom network, they cannot resolve each other's names.
Final Answer:
Containers were started without specifying the network. -> Option D
Quick Check:
Containers must join network explicitly = C [OK]
Hint: Always use --network to attach containers to custom networks [OK]
Common Mistakes:
Assuming network auto-attachment
Blaming network driver without checking container config
Restarting containers unnecessarily
5. You want to run three containers: frontend, backend, and database. You want frontend to communicate only with backend, and backend to communicate with database, but frontend should NOT talk directly to database. How can you achieve this using Docker custom networks?
hard
A. Run all containers on one custom network and rely on container names to restrict access.
B. Attach all containers to the default network and use firewall rules inside containers.
C. Create two custom networks: one for frontend-backend, another for backend-database, and attach containers accordingly.
D. Use host networking mode for all containers.
Solution
Step 1: Understand network isolation
Docker networks isolate containers; containers on different networks cannot communicate unless attached to both.
Step 2: Design network setup
Create two networks: one connecting frontend and backend, another connecting backend and database. Attach frontend and backend to first network, backend and database to second.
Step 3: Resulting communication
Frontend can reach backend, backend can reach database, but frontend cannot reach database directly.
Final Answer:
Create two custom networks: one for frontend-backend, another for backend-database, and attach containers accordingly. -> Option C
Quick Check:
Separate networks control container communication = A [OK]
Hint: Use multiple custom networks to control container access [OK]
Common Mistakes:
Using one network expecting access control by names
Relying on default network for isolation
Using host networking which disables isolation
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.