feat(lab-02): complete Phase 3 - Network & VPC lab

Implement Lab 02 with Docker bridge networks simulating VPC/Subnets.

Test Infrastructure (RED phase):
- 6 bash test scripts for network creation, isolation, INF-02 compliance
- Fail-fast orchestration with run-all-tests.sh
- Quick validation script for development

Documentation (Diátaxis framework):
- 3 tutorials: VPC creation, container deployment, isolation verification
- 4 how-to guides: create network, inspect config, test isolation, cleanup
- 3 reference docs: Docker network commands, Compose syntax, VPC mapping
- 1 explanation: Docker ↔ VPC parallels (PARA-01/02/03/04)

Infrastructure (GREEN phase):
- docker-compose.yml with VPC networks (10.0.1.0/24, 10.0.2.0/24)
- 5 services: web, app, db, test-public, test-private
- INF-02 compliant: 127.0.0.1 bindings only, no 0.0.0.0
- Private network with --internal flag
- Multi-homed app container (public + private networks)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Luca Sacchi Ricciardi
2026-03-25 17:26:35 +01:00
parent d4c4f7d717
commit 5b2c8c37aa
22 changed files with 3988 additions and 12 deletions

View File

@@ -0,0 +1,89 @@
# How-To: Ispezionare la Configurazione di Rete
Guida per analizzare e debuggare le reti Docker.
## Ispezionare una Rete Specifica
```bash
docker network inspect NETWORK_NAME
```
Output JSON con: Subnet, Gateway, Driver, Container collegati.
## Comandi Utili
### Mostra Solo le Informazioni Importanti
```bash
# Subnet e Gateway
docker network inspect my-network --format '{{range .IPAM.Config}}{{.Subnet}} (GW: {{.Gateway}}){{end}}'
# Solo container collegati
docker network inspect my-network --format '{{range .Containers}}{{.Name}} {{.IPv4Address}}{{end}}'
# Driver e Scope
docker network inspect my-network --format 'Driver: {{.Driver}}, Scope: {{.Scope}}'
```
### Vedere i Container in una Rete
```bash
# Metodo 1: Tramite inspect
docker network inspect my-network --format '{{json .Containers}}' | jq '.[] | .Name'
# Metodo 2: Tramite docker ps con filtro
docker ps --filter "network=my-network" --format "{{.Names}}"
```
### Verificare IP di un Container
```bash
# Tutti gli IP del container
docker inspect container-name --format '{{range .NetworkSettings.Networks}}{{.Network}}: {{.IPAddress}}{{end}}'
# IP in una rete specifica
docker inspect container-name --format '{{range $k, $v := .NetworkSettings.Networks}}{{if eq $k "my-network"}}{{$v.IPAddress}}{{end}}{{end}}'
```
### Debug con Output Formattato
```bash
# Tabella container -> IP -> Rete
docker ps --format "{{.Names}}" | while read c; do
echo "Container: $c"
docker inspect $c --format '{{range $k, $v := .NetworkSettings.Networks}} {{$k}}: {{$v.IPAddress}}{{end}}'
done
```
## Risoluzione Problemi
### Rete Non Trovata
```bash
# Verifica esistenza rete
docker network ls | grep my-network
# Se non esiste, creala
docker network create my-network
```
### Container Non in Rete
```bash
# Collega container a rete
docker network connect my-network container-name
# Scollega container da rete
docker network disconnect my-network container-name
```
### Subnet Conflicts
```bash
# Trova subnet in conflitto
docker network ls -q | xargs docker network inspect --format '{{.Name}}: {{range .IPAM.Config}}{{.Subnet}}{{end}}' | grep "10.0.1"
```
## Vedi Anche
- [Reference: Compose Network Syntax](../reference/compose-network-syntax.md)