الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

الفصل 7الاسم في الدورة: Container networking

Connect containers with networks

Containers talk to each other and to the outside through networks. On a user-defined network they find each other by name; published ports make a service reachable from the host or the internet.

  • 4 الدروس
  • 5 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

7.1

Know the network drivers

The driver decides how the container is connected.

DriverMeaning
bridge (default)A private network on the host, NAT to the outside
User-defined bridgeLike bridge, plus DNS by container name — use this
hostNo isolation: the container uses the host's network
noneNo network at all
macvlan / ipvlanThe container gets an address on the physical LAN
overlayAcross several hosts (Swarm)

الأوامر في هذا الدرس

7.2

Use a user-defined network

Containers on the same user-defined network reach each other by name. Only the front service publishes a port.

docker network create shopnet
docker run -d --name db --network shopnet -e POSTGRES_PASSWORD=secret postgres:16
docker run -d --name api --network shopnet -e DATABASE_URL=postgres://postgres:secret@db:5432/postgres myorg/api:2.0
docker run -d --name web --network shopnet -p 8080:80 nginx:1.27
docker exec api getent hosts db
docker network inspect shopnet --format '{{range .Containers}}{{.Name}} {{.IPv4Address}}{{"\n"}}{{end}}'

تذكّر

The database publishes no port. It is reachable only for containers on shopnet — a smaller attack surface.

الأوامر في هذا الدرس

7.3

Publish ports carefully

-p opens a port on the host. By default it listens on all host addresses.

docker run -d -p 8080:80 nginx:1.27
docker run -d -p 127.0.0.1:5432:5432 postgres:16
docker run -d -P nginx:1.27
docker port $(docker ps -lq)

انتبه

Docker writes its own firewall (iptables/nftables) rules. A published port can be reachable from the internet even if your host firewall seems to block it. Bind to 127.0.0.1 when only local access is needed.

الأوامر في هذا الدرس

7.4

Debug container networking

Test from inside the container, step by step: name → IP → port.

docker exec api getent hosts db
docker exec api sh -c 'nc -zv db 5432'
docker run --rm -it --network shopnet nicolaka/netshoot
docker network ls
docker network disconnect shopnet web

netshoot is a debug image with dig, curl, tcpdump, ss and more — join the same network and test.

كل الأوامر في هذا الفصل