
docker-networking
Guidance for Docker networking configuration and inter-container communication. Covers network modes (bridge/host/overlay/none/macvlan/ipvlan), custom bridge networks with DNS resolution, port publishing (-p/--publish), container linking and service discovery, network troubleshooting (inspect/ping/nslookup), overlay networks for Swarm, and network security (internal networks, encrypted overlay). Use when the user asks about docker network, container networking, bridge mode, port mapping, inter-container communication, network troubleshooting, or Docker network modes. 使用场景:docker network、容器网络、bridge、overlay、端口映射、容器通信、网络配置、网络排查.
- Installs
- 112
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/full-stack-skills/docker-skills --skill docker-networking- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads docker-networking automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Docker Networking — 网络配置与容器通信
Comprehensive guidance for Docker networking modes, configuration, and troubleshooting.
When to Use
ALWAYS use this skill when the user mentions:
- "docker network", "容器网络"
- "bridge network", "host network", "overlay network"
- "端口映射", "publish port"
- "容器之间怎么通信", "跨容器通信"
- "网络不通", "network troubleshooting"
Network Mode Comparison
| Mode | Isolation | Use Case | Cross-Host? |
|---|---|---|---|
| bridge (default) | Container-level | Single-host containers | ❌ |
| host | None (share host) | Max performance, no isolation | ❌ |
| overlay | Container-level | Swarm multi-host | ✅ |
| none | Full | No networking needed | ❌ |
| macvlan/ipvlan | MAC/IP-level | Legacy apps needing physical IP | ✅ |
Custom Bridge Network (Recommended)
# Create a custom network
docker network create --driver bridge mynet
# Run containers on it
docker run -d --name app1 --network mynet nginx:alpine
docker run -d --name app2 --network mynet nginx:alpine
# DNS resolution works automatically
docker exec app1 ping app2 # ✅ responds
docker exec app1 nslookup app2 # ✅ resolves
# Benefits over default bridge:
# - Automatic DNS resolution
# - Container isolation from default bridge
# - Can connect/disconnect at runtime
Port Publishing
# Basic port mapping
docker run -p 8080:80 nginx # host:8080 → container:80
docker run -p 8080 # random host port → container:8080
docker run -P nginx # publish all EXPOSE'd ports to random host ports
# Multiple ports
docker run -p 8080:80 -p 8443:443 nginx
# Bind to specific interface
docker run -p 127.0.0.1:8080:80 nginx # only localhost
Service Discovery
Custom bridge network provides automatic DNS:
┌──────────────────────────────────┐
│ my-network (bridge) │
│ │
│ ┌──────┐ ┌──────┐ ┌──────┐ │
│ │ app1 │ │ app2 │ │ db │ │
│ └──┬───┘ └──┬───┘ └──┬───┘ │
│ │ │ │ │
│ └─── DNS: app2 → 172.18.0.3 │
│ DNS: db → 172.18.0.4 │
└──────────────────────────────────┘
app1 can connect to db:5432 directly — no IP needed!
Overlay Network (Swarm)
# Create overlay for multi-host
docker network create --driver overlay --attachable my-overlay
# In compose:
networks:
backend:
driver: overlay
Network Troubleshooting
# Inspect network details
docker network inspect mynet
# Test connectivity from container
docker exec app1 ping -c 3 app2
docker exec app1 nslookup db
docker exec app1 curl http://app2:8080/health
# Check iptables (host)
sudo iptables -t nat -L DOCKER -n
Workflow — 推荐配置流程
Step 1: 确定需求: 容器间通信?端口暴露?跨主机?选择网络模式
Step 2: 创建网络: docker network create --driver bridge mynet
Step 3: 启动容器: docker run -d --network mynet --name db mysql + docker run -d --network mynet --name api myapp
Step 4: 验证连通性: docker exec api ping db(服务名 DNS 解析)
Step 5: 排查问题: docker network inspect mynet → docker exec api nslookup db
Gotchas — Common Pitfalls
- Default bridge no DNS: Containers on the default bridge CANNOT resolve each other by name. → Recovery:
docker network create mynet && docker run --network mynet ...; always use custom bridge networks. - Port already in use:
-p 8080:80fails if host port 8080 is taken. → Recovery:lsof -i :8080to find the process; use-p 8081:80or-p 80for random host port. - Mac host networking limitation:
--network hoston Docker Desktop (Mac) joins the VM's network, not the Mac's. → Recovery: Publish ports with-pinstead of--network host. - Overlay without Swarm: Overlay networks only work with Swarm mode. → Recovery:
docker swarm initfirst, or add--attachableflag for standalone containers. - EXPOSE does NOT publish:
EXPOSEin Dockerfile is documentation only. → Recovery: Always use-por Composeports:to actually make ports accessible.
Boundary — 能力边界(适用与不适用场景)
| 分类 | 场景 | 说明 |
|---|---|---|
| ✅ 能做 | 单机容器网络配置 | bridge/host/none 模式选择 |
| ✅ 能做 | 容器间 DNS 通信 | 自定义 bridge 网络 + 服务名解析 |
| ✅ 能做 | 端口发布 | -p host:container 端口映射 |
| ⚠️ 需条件 | 跨主机通信 | 需要 overlay 网络 + Swarm 模式 |
| ⚠️ 需条件 | macOS --network host | 行为不同于 Linux,建议用 -p 替代 |
| ❌ 超范围 | K8s 网络策略(NetworkPolicy) | 使用 docker-production + K8s 文档 |
| ❌ 超范围 | 外部负载均衡(Nginx/HAProxy) | 基础设施层级 |
| ❌ 超范围 | iptables/nftables 精细配置 | Linux 网络管理 |
When NOT to Use This Skill
| ❌ Skip | ✅ Use Instead |
|---|---|
| Docker basics | docker-basics |
| Running containers | docker-run |
| Compose networking | docker-compose (compose handles network creation automatically) |
| Kubernetes networking | K8s documentation |
Security & Stability
- Use
--internalflag for networks that should not have internet access. - Encrypt overlay network traffic:
--opt encrypted=true. - Avoid
--network hostin production — no network isolation. - No executable scripts bundled. Guidance only.
📚 官方文档参考
🧭 Docker Skills Journey
📍 You are here:
docker-networking— 网络配置
← Previous: docker-run | → Next: docker-compose
FAQ
Q1: 如何快速上手此技能? A: 参考上方的快速开始章节,按步骤操作即可。
Q2: 遇到版本不兼容问题怎么办? A: 检查依赖版本,使用 lock 文件锁定,参考常见陷阱章节。
Q3: 如何在生产环境使用? A: 参考最佳实践章节,确保配置正确,做好监控和日志。
Q4: 性能如何优化? A: 参考性能优化相关文档,使用缓存、索引等手段。
Q5: 如何贡献或反馈问题? A: 在 GitHub 仓库提交 Issue 或 Pull Request。
Q6: 是否支持中文? A: 支持中文文档和中文注释,详见国内适配章节。
FAQ
What does the docker-networking skill do?
Guidance for Docker networking configuration and inter-container communication. Covers network modes (bridge/host/overlay/none/macvlan/ipvlan), custom bridge networks with DNS resolution, port publishing (-p/--publish), container linking and service discovery, network troubleshooting (inspect/ping/nslookup), overlay networks for Swarm, and network security (internal networks, encrypted overlay). Use when the user asks about docker network, container networking, bridge mode, port mapping, inter-container communication, network troubleshooting, or Docker network modes. 使用场景:docker network、容器网络、bridge、overlay、端口映射、容器通信、网络配置、网络排查.
How do I install docker-networking?
Run npx skills add https://github.com/full-stack-skills/docker-skills --skill docker-networking in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/docker-networking/ (personal) or .claude/skills/docker-networking/ (project).
Which AI agents can use docker-networking?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is docker-networking safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains docker-networking?
It is published by full-stack-skills in full-stack-skills/docker-skills. It has 112 recorded installs.
More from full-stack-skills/docker-skills
docker-compose
full-stack-skills/docker-skills
Expert guidance for Docker Compose — writing production-grade compose.yml files for multi-container applications. Covers complete Compose file syntax (services, networks, volumes, secrets, configs, profiles, extends, include), service configuration (image/build, ports, environment, envfile, dependson with health checks, deploy resources, restart policies), networking in Compose (default networks, custom networks, internal networks), volume management, environment variable strategies (.env vs environment vs envfile), override files for multi-environment, profiles for optional services, and migration to Kubernetes with kompose. Use when the user asks about docker compose, docker-compose.yml, compose file, multi-container, service orchestration, compose configuration, or needs to write/modify a compose file. 使用场景:docker compose、docker-compose.yml、compose 文件、多容器、服务编排、compose 配置、dependson、profiles.
docker-dockerfile
full-stack-skills/docker-skills
Open the skill to read its SKILL.md instructions.
docker-security
full-stack-skills/docker-skills
Guidance for Docker security hardening across the full lifecycle — image security (minimal base images, non-root users, pinned versions), runtime security (seccomp/AppArmor/SELinux, capabilities, read-only rootfs, no-new-privileges), secrets management (BuildKit secrets, Docker secrets in Swarm), Docker Bench Security auditing, CIS compliance checklist, and supply-chain security (image signing, content trust, SBOM). Use when the user asks about Docker security, image hardening, non-root containers, seccomp, AppArmor, Docker Bench, secrets management, or securing containers. 使用场景:docker 安全、镜像安全、非root运行、seccomp、AppArmor、security、Docker Bench、secret管理.
docker-troubleshooting
full-stack-skills/docker-skills
Open the skill to read its SKILL.md instructions.
docker-basics
full-stack-skills/docker-skills
Open the skill to read its SKILL.md instructions.
docker-buildx
full-stack-skills/docker-skills
Open the skill to read its SKILL.md instructions.
Popular devops & cloud skills
microsoft-foundry
microsoft/azure-skills
Build, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and resources end to end. USE FOR: foundry, azd ai agent, azd provision/deploy, hosted agent scaffold/develop/run/deploy/troubleshoot, prompt agent create, managed harness agent create, GitHub Copilot harness agent, create agent, update agent, add tool to agent, invoke agent, agent insights, evaluate agent, batch eval, continuous eval, continuous monitoring, agent CI/CD, optimize prompt, improve prompt, optimize agent instructions, Agent Optimizer scaffold, dataset curation from traces, deploy model, model fine-tuning (SFT/DPO/RFT), Foundry project, RBAC, role assignment, permissions, quota, capacity, region, deployment failure, AI Services, create Foundry resource, knowledge index, customize deployment, onboard, availability, training-data, grader, distillation, large file upload. DO NOT USE FOR: Azure Functions, App Service, general Azure deploy (use azure-deploy), general Azure prep (use azure
azure-diagnostics
microsoft/azure-skills
Debug Azure production issues on Azure using AppLens, Azure Monitor, resource health, and safe triage. WHEN: debug production issues, troubleshoot app service, app service high CPU, app service deployment failure, troubleshoot container apps, container app 503 or target port mismatch, troubleshoot functions, function telemetry missing or stopped after a config/connection-string change, troubleshoot AKS, VM RDP, Linux SSH, VM black screen, can't connect to VM, reset VM password, NSG or firewall blocking, kubectl cannot connect, kube-system/CoreDNS failures, pod pending, crashloop, node not ready, upgrade failures, analyze logs, KQL, insights, image pull failures, cold start issues, health probe failures, resource health, root cause of errors, troubleshoot event hubs, troubleshoot service bus, messaging SDK error, AMQP connection failure, message lock lost, lock renewal during long-running processing, service bus dead letter.
azure-prepare
microsoft/azure-skills
Prepare azd-based Azure projects for deployment: generates azure.yaml, infrastructure (Bicep/Terraform), and Dockerfiles for the Azure Developer CLI (azd) workflow. USE ONLY when the user explicitly wants to use azd as the deployment tool, or the project already has an azure.yaml file. DO NOT USE FOR: non-azd deployments, Python App Service code-only deploys (use python-appservice-deploy), or cross-cloud migration (use azure-cloud-migrate). WHEN: prepare app for azd, create azure.yaml, set up azd infrastructure, modernize app for Azure with azd, deploy with azd, function app, timer trigger, service bus trigger, event-driven function, managed identity, generate Bicep, generate Terraform, create and deploy to Azure.
azure-ai
microsoft/azure-skills
Use for Azure AI: Search, Speech, OpenAI, Document Intelligence. Helps with search, vector/hybrid search, speech-to-text, text-to-speech, transcription, OCR. WHEN: AI Search, query search, vector search, hybrid search, semantic search, speech-to-text, text-to-speech, transcribe, OCR, convert text to speech.
azure-deploy
microsoft/azure-skills
Execute Azure deployments for ALREADY-PREPARED applications that have existing .azure/deployment-plan.md and infrastructure files. DO NOT use this skill when the user asks to CREATE a new application — use azure-prepare instead. This skill runs azd up, azd deploy, terraform apply, and az deployment commands with built-in error recovery. Requires .azure/deployment-plan.md from azure-prepare and validated status from azure-validate. WHEN: "run azd up", "run azd deploy", "execute deployment", "push to production", "push to cloud", "go live", "ship it", "bicep deploy", "terraform apply", "publish to Azure", "launch on Azure". DO NOT USE WHEN: "create and deploy", "build and deploy", "create a new app", "set up infrastructure", "create and deploy to Azure using Terraform" — use azure-prepare for these.
azure-validate
microsoft/azure-skills
Pre-deployment validation for Azure readiness. Run deep checks on configuration, infrastructure (Bicep or Terraform), RBAC role assignments, managed identity permissions, and prerequisites before deploying. WHEN: validate my app, check deployment readiness, run preflight checks, verify configuration, check if ready to deploy, validate azure.yaml, validate Bicep, test before deploying, troubleshoot deployment errors, validate Azure Functions, validate function app, validate serverless deployment, verify RBAC roles, check role assignments, review managed identity permissions, what-if analysis, validate Container Apps deployment.