con un clic
dind-network-host-pattern
Docker-in-Docker with network_mode host for multi-node simulation
Menú
Docker-in-Docker with network_mode host for multi-node simulation
| name | dind-network-host-pattern |
| description | Docker-in-Docker with network_mode host for multi-node simulation |
| tags | ["docker","dind","testing","infrastructure"] |
When simulating a multi-node deployment with Docker-in-Docker, use network_mode: host inside the DinD containers. This makes inner containers bind to the DinD container's network namespace, preserving the outer network's IP addressing.
Outer docker-compose (host)
├── service-a DinD container → fixed IP 10.0.0.2
│ └── inner container (network_mode: host) → binds to 10.0.0.2
├── service-b DinD container → fixed IP 10.0.0.3
│ └── inner container (network_mode: host) → binds to 10.0.0.3
Build on host, save to per-node cache directories, load inside DinD:
# Host: save image
docker save myimage:latest | gzip > image-cache/node-a/myimage.tar.gz
# DinD entrypoint: load image
for img in /image-cache/*.tar.gz; do
gunzip -c "$img" | docker load
done
Use nested exec (outer → inner) to interact with inner containers:
# Exec into inner container via outer DinD
docker compose exec -T dind-node-a \
docker compose -f /compose/docker-compose.yml exec -T service-a <command>
x-dind-common: &dind-common
image: docker:dind
privileged: true
environment:
DOCKER_TLS_CERTDIR: ""
entrypoint: ["/compose/entrypoint.sh"]
restart: unless-stopped
services:
dind-node-a:
<<: *dind-common
volumes: [...]
networks:
net:
ipv4_address: 10.0.0.2
docker:dind requires privileged: trueDOCKER_TLS_CERTDIR="" to disable TLS (simplifies test environments)Universal coding standards, best practices, and patterns. Use when developing in any language — triggers on TypeScript, JavaScript, React, Node.js, Python, Nix, ruff, pyright, pytest, uv, flake.nix, justfile, just, recipes, and general code quality topics.
Use when writing git commit messages, reviewing commits, or setting up commit conventions. Triggers on commit, git commit, commit message, changelog, semantic versioning.
A formal evaluation framework for Claude Code sessions, implementing eval-driven development (EDD) principles.
Audit NixOS impermanence configuration — find files on root filesystem not covered by persistence declarations. Use when the user wants to check for untracked files, audit impermanence, or runs /impermanence-audit.
Use when implementing LangGraph workflows that need to pause for user input or external confirmation before continuing execution
Workaround for @nuxt/eslint not auto-detecting TypeScript, causing vue-eslint-parser to fail on <script lang="ts"> blocks