Script Valley
Docker: Complete Course
Docker Networking/Assessment

Practice & Assessment

Test your understanding of Docker Networking

Multiple Choice Questions

6
1

Two containers are on the default bridge network. Container A tries to connect to Container B using its container name. What happens?

2

What does `-p 127.0.0.1:5432:5432` do compared to `-p 5432:5432`?

3

What does the EXPOSE instruction in a Dockerfile actually do at runtime?

4

You need containers A and B to communicate with each other, but neither should be accessible from the internet. Which approach is correct?

5

What is a network alias in Docker used for?

6

A container can reach a database by IP but not by hostname. What is the most likely cause?

Coding Challenges

1
1

Wire a Node.js API to Redis using a custom Docker network

Create a custom Docker bridge network named 'cache-net'. Run a Redis 7 container named 'redis' on that network with no port mapping to the host. Run a second container from the image 'node:20-alpine' named 'api-test' on the same network, opening an interactive shell. From inside 'api-test', install redis-cli via apk, then run `redis-cli -h redis ping` and verify you get PONG. Then run `redis-cli -h redis set greeting hello` and `redis-cli -h redis get greeting` to confirm read-write access. Document all commands. Then repeat the exercise on the default bridge (no custom network) and observe that hostname 'redis' fails to resolve. Estimated time: 20 minutes.

Easy

Mini Project

1

Isolated Three-Tier Network Architecture

Design a three-container system with isolated network tiers using only Docker CLI commands (no Compose). Create two networks: 'frontend-net' and 'backend-net'. Run three containers: (1) an nginx container named 'web' on frontend-net with port 80 mapped to host port 8080, (2) a Node.js API container named 'api' connected to both networks so it bridges the tiers, (3) a PostgreSQL 16 container named 'db' on backend-net only with no port mapping to the host. Configure the API container's DB_HOST env var as 'db' and verify from inside 'api' that you can reach 'db' by name. Verify from inside 'web' that you can reach 'api' by name but cannot reach 'db' by name (DNS should fail). Document each command and the result of the connectivity tests, explaining why the isolation works.

Medium