Skip to content
Guest
Learn Docker · Course Syllabus Show lessons
Networking & Persistence · 8 min read · Intermediate

Docker Networks & Internal DNS

Isolate backend databases on private bridge networks so only your reverse proxy is exposed to the public internet.

What you'll learn

  • Create custom user-defined bridge networks with docker network create
  • Understand why user-defined bridge networks provide automatic container-name DNS
  • Keep database ports private by omitting ports: on db services

In production, your PostgreSQL or Redis container should never publish 5432:5432 to the public internet. Instead, attach api and db to the same private Docker bridge network so api talks to db:5432 internally while only Nginx (80/443) faces the outside world.

Fill-in-the-Blank Exercise

Create & Attach a Private Network

Create a bridge network named app_net and attach a container to it.

docker  create app_net
docker run -d -- app_net --name db postgres:16-alpine

Live Network Reference Lab

Bashdocker_network.sh
Expected OutputClick “Run Live” to compile with GNU Bash
# Private backend network: db is unreachable from outside the host
docker network create app_net
docker run -d --network app_net --name db postgres:16-alpine
docker run -d --network app_net -p 8080:8080 --name api my-api:1.0

Check Your Understanding

Score: 0 / 1

1. How do you allow an api container to reach a postgres container on port 5432 without exposing port 5432 to the public internet?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind