-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Replicate --add-host behavior with extra_hosts #12088
Copy link
Copy link
Closed
compose-spec/compose-go
#678Description
Description
In a docker run command, you can add multiple IP addresses for a single hostname. In a compose file, you can only set one IP per host.
docker run --rm --name tester --add-host myhost:0.0.0.1 --add-host myhost:0.0.0.2 alpine cat /etc/hosts
In a compose file, extra_hosts in long syntax won't pass validation if it sees duplicate keys. Short syntax will allow two hosts with the same IP, but overwrites any previous entries with the last entry for the same hostname.
services:
tester:
image: alpine
container_name: tester
extra_hosts:
- "myhost=0.0.0.1"
- "myhost=0.0.0.2"
command: cat /etc/hosts
Reactions are currently unavailable