Skip to content
Back to skills

Docker Networking

ASecurity

Configure Docker networking for containers including bridge, overlay, and service discovery

  • 754 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added February 8, 2026
developmentbashnodedockerdebuggingdatabasefrontendbackendperformance

Security analysis

A96/100
  • mediumUses curl or wget to download content

Pro shows the line behind each finding and how to fix it

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill docker-networking --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Docker Networking?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Docker Networking
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-docker-networking/badge)](https://www.skillsdirectory.com/skills/majiayu000-docker-networking)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: docker-networking
description: Configure Docker networking for containers including bridge, overlay, and service discovery
sasmp_version: "1.3.0"
bonded_agent: 03-docker-networking
bond_type: PRIMARY_BOND
---

# Docker Networking Skill

Master Docker networking concepts and configuration for container communication, service discovery, and network isolation.

## Purpose

Configure and troubleshoot Docker networks for development and production environments with proper isolation and service discovery.

## Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| driver | enum | No | bridge | bridge/overlay/host/macvlan |
| subnet | string | No | - | Custom subnet CIDR |
| internal | boolean | No | false | Internal-only network |

## Network Drivers

| Driver | Use Case | Multi-Host | Encryption |
|--------|----------|------------|------------|
| bridge | Single host, default | No | No |
| overlay | Swarm, multi-host | Yes | Optional |
| host | Max performance | No | N/A |
| macvlan | Physical network | No | No |
| none | Disable networking | No | N/A |

## Configuration Examples

### Custom Bridge Network
```bash
# Create network with custom subnet
docker network create \
  --driver bridge \
  --subnet 172.28.0.0/16 \
  --gateway 172.28.0.1 \
  my_network

# Run container on network
docker run -d --name app \
  --network my_network \
  nginx:alpine
```

### Docker Compose Networking
```yaml
services:
  frontend:
    image: nginx:alpine
    networks:
      - public
    ports:
      - "80:80"

  backend:
    image: node:20-alpine
    networks:
      - public
      - private
    expose:
      - "3000"

  database:
    image: postgres:16-alpine
    networks:
      - private  # Internal only

networks:
  public:
    driver: bridge
  private:
    driver: bridge
    internal: true  # No external access
```

### Service Discovery
```yaml
# Containers can reach each other by service name
services:
  app:
    image: myapp
    environment:
      # Use service name as hostname
      DATABASE_HOST: database
      CACHE_HOST: redis

  database:
    image: postgres:16-alpine

  redis:
    image: redis:alpine
```

### Overlay Network (Swarm)
```bash
# Create encrypted overlay
docker network create \
  --driver overlay \
  --attachable \
  --opt encrypted \
  my_overlay
```

## Port Mapping

```bash
# Map host:container
docker run -p 8080:80 nginx

# Bind to specific interface
docker run -p 127.0.0.1:8080:80 nginx

# Random host port
docker run -P nginx

# UDP port
docker run -p 53:53/udp dnsserver
```

## Error Handling

### Common Errors
| Error | Cause | Solution |
|-------|-------|----------|
| `network not found` | Typo or deleted | Create network |
| `address in use` | Port conflict | Change port |
| `cannot reach` | Wrong network | Check network membership |
| `DNS failed` | Service not ready | Add health checks |

### Fallback Strategy
1. Verify network exists: `docker network ls`
2. Check container membership: `docker network inspect <net>`
3. Test DNS: `docker exec app nslookup backend`

## Troubleshooting

### Debug Checklist
- [ ] Network created? `docker network ls`
- [ ] Container connected? `docker inspect <container>`
- [ ] DNS resolving? `nslookup` from container
- [ ] Port mapped? `docker port <container>`

### Diagnostic Commands
```bash
# List networks
docker network ls

# Inspect network
docker network inspect my_network

# Test connectivity
docker exec app ping -c 3 database

# Check DNS
docker exec app nslookup backend

# View port mappings
docker port container_name
```

### Network Debugging
```bash
# Enter container network namespace
docker exec -it app sh

# Check DNS resolution
cat /etc/resolv.conf
nslookup database

# Check connectivity
ping -c 3 backend
curl http://backend:3000/health
```

## Usage

```
Skill("docker-networking")
```

## Related Skills
- docker-compose-setup
- docker-swarm

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.