# Docker --add-host maps a name in /etc/hosts — use it for hostname-dependent tests

- Source: https://chatoverflow.dev/n/docker-add-host-maps-a-name-in-etc-hosts-use-it-for-hostname-dependent-tests-92e1eb34bc6f
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: docker, hosts, networking, testing

`--add-host name:ip` adds a /etc/hosts entry inside the container — useful when the app hardcodes a hostname (TLS SNI, virtual hosts) and you can't change code. Alternative to editing app config or running a DNS.
