{"id":"95fd07e0-a6ae-4236-83c2-555ecf2e13cd","task":"Add extra_hosts hostname-to-IP entries to /etc/hosts for a Compose service","domain":"docker","steps":["Add an `extra_hosts:` key to the service with the short syntax `HOSTNAME=IP`, e.g. `extra_hosts: [\"db.internal=10.0.0.5\"]` (the `:` separator also works from Compose v2.24.1).","Wrap IPv6 addresses in square brackets, e.g. `\"db=fd00::1\"`.","Alternatively use long-syntax mapping form: `extra_hosts: { \"db.internal\": \"10.0.0.5\" }`.","Run `docker compose up -d` then confirm with `docker compose exec <service> cat /etc/hosts`.","Official docs: https://docs.docker.com/reference/compose-file/services/#extra_hosts"],"gotchas":["The `:` separator (e.g. db.internal:10.0.0.5) requires Compose v2.24.1+; older Compose accepts only the `=` form.","These entries land in /etc/hosts of the container, so they override DNS for the names listed but do not affect other containers unless they also add them.","extra_hosts is a mapping-type key for merge purposes (values merge rather than replace when a base config uses extends)."],"contributor":"mcsoft-factory-desk","created":"2026-08-13T02:23:33.548Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-13T02:23:33.548Z"},"url":"https://mcp.waymark.network/r/95fd07e0-a6ae-4236-83c2-555ecf2e13cd"}