
- Installs
- 79
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/chaterm/terminal-skills --skill 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 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 容器网络
概述
容器网络模式、跨主机通信等技能。
网络驱动
网络类型
# bridge(默认)- 单主机容器通信
# host - 共享主机网络
# none - 无网络
# overlay - 跨主机通信(Swarm)
# macvlan - 分配 MAC 地址
查看网络
# 列出网络
docker network ls
# 网络详情
docker network inspect bridge
docker network inspect network_name
# 查看容器网络
docker inspect container_name --format '{{json .NetworkSettings.Networks}}'
Bridge 网络
默认 bridge
# 容器使用默认 bridge
docker run -d --name web nginx
# 查看 IP
docker inspect web --format '{{.NetworkSettings.IPAddress}}'
# 默认 bridge 容器间通过 IP 通信
# 不支持容器名解析
自定义 bridge
# 创建网络
docker network create mynet
docker network create --driver bridge --subnet 172.20.0.0/16 mynet
# 使用自定义网络
docker run -d --name web --network mynet nginx
docker run -d --name api --network mynet myapi
# 自定义网络支持容器名解析
docker exec api ping web
连接多个网络
# 创建网络
docker network create frontend
docker network create backend
# 容器连接多个网络
docker run -d --name app --network frontend myapp
docker network connect backend app
# 断开网络
docker network disconnect frontend app
Host 网络
# 使用主机网络
docker run -d --network host nginx
# 容器直接使用主机端口
# 无需端口映射
# 性能最好,但端口可能冲突
None 网络
# 无网络
docker run -d --network none myapp
# 完全隔离,无网络访问
# 适用于安全敏感场景
端口映射
# 映射端口
docker run -d -p 8080:80 nginx # HOST:CONTAINER
docker run -d -p 80:80 -p 443:443 nginx # 多端口
docker run -d -p 127.0.0.1:8080:80 nginx # 绑定特定 IP
docker run -d -P nginx # 随机端口
# 查看端口映射
docker port container_name
DNS 配置
# 自定义 DNS
docker run -d --dns 8.8.8.8 nginx
docker run -d --dns 8.8.8.8 --dns 8.8.4.4 nginx
# 自定义主机名
docker run -d --hostname myhost nginx
# 添加 hosts 记录
docker run -d --add-host db:192.168.1.100 nginx
网络别名
# 创建网络
docker network create mynet
# 使用别名
docker run -d --name web --network mynet --network-alias webserver nginx
# 其他容器可通过别名访问
docker run --rm --network mynet busybox ping webserver
Overlay 网络(Swarm)
# 初始化 Swarm
docker swarm init
# 创建 overlay 网络
docker network create -d overlay myoverlay
# 创建可附加的 overlay(非 Swarm 服务也可使用)
docker network create -d overlay --attachable myoverlay
# 在服务中使用
docker service create --name web --network myoverlay nginx
Macvlan 网络
# 创建 macvlan 网络
docker network create -d macvlan \
--subnet=192.168.1.0/24 \
--gateway=192.168.1.1 \
-o parent=eth0 \
mymacvlan
# 使用 macvlan
docker run -d --network mymacvlan --ip 192.168.1.100 nginx
# 容器获得独立 MAC 地址,可直接在物理网络通信
网络诊断
容器内诊断
# 进入容器
docker exec -it container_name sh
# 网络工具
apt-get update && apt-get install -y iputils-ping curl netcat-openbsd
# 或使用 netshoot
docker run -it --network container:target_container nicolaka/netshoot
常用诊断命令
# 查看容器 IP
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name
# 查看网络中的容器
docker network inspect mynet -f '{{range .Containers}}{{.Name}} {{.IPv4Address}}{{"\n"}}{{end}}'
# 测试连通性
docker exec container1 ping container2
docker exec container1 curl http://container2:80
常见场景
场景 1:容器间通信
# 创建网络
docker network create app-network
# 启动数据库
docker run -d --name db --network app-network postgres
# 启动应用(通过容器名访问数据库)
docker run -d --name app --network app-network \
-e DATABASE_URL=postgres://db:5432/mydb \
myapp
场景 2:隔离前后端
# 创建网络
docker network create frontend
docker network create backend
# 前端只在 frontend
docker run -d --name nginx --network frontend -p 80:80 nginx
# 后端连接两个网络
docker run -d --name api --network frontend myapi
docker network connect backend api
# 数据库只在 backend
docker run -d --name db --network backend postgres
场景 3:调试网络问题
# 使用 netshoot 调试
docker run -it --rm --network container:target nicolaka/netshoot
# 常用命令
ip addr
ss -tlnp
curl -v http://service:port
tcpdump -i eth0
nslookup service_name
场景 4:限制网络带宽
# 使用 tc 限制带宽(需要 NET_ADMIN 权限)
docker run -d --cap-add NET_ADMIN myapp
# 在容器内
tc qdisc add dev eth0 root tbf rate 1mbit burst 32kbit latency 400ms
故障排查
| 问题 | 排查方法 |
|---|---|
| 容器间无法通信 | 检查是否在同一网络 |
| DNS 解析失败 | 检查是否使用自定义网络 |
| 端口无法访问 | 检查端口映射、防火墙 |
| 网络性能差 | 考虑使用 host 网络 |
# 检查网络配置
docker network inspect network_name
# 检查容器网络
docker inspect container_name | jq '.[0].NetworkSettings'
# 检查 iptables 规则
iptables -L -n -t nat
FAQ
What does the networking skill do?
Docker 容器网络
How do I install networking?
Run npx skills add https://github.com/chaterm/terminal-skills --skill 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/networking/ (personal) or .claude/skills/networking/ (project).
Which AI agents can use 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 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 networking?
It is published by chaterm in chaterm/terminal-skills. It has 79 recorded installs.
More from chaterm/terminal-skills
system-admin
chaterm/terminal-skills
Linux system administration and monitoring
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.