Reputation: 71
I'm trying to create a container based on PHP:5-apache with many virtual hosts like
account.site1.local
account.site2.local
account.site3.local
I can add all the vhosts with a wildcard on the apache conf. Is it possible to do something similar for the hosts file?
Upvotes: 2
Views: 5285
Reputation: 19184
Docker sets up the hosts
file when you run a container, so you don't want to manually edit it. Instead you can use the add-host
option:
> docker run --add-host 1.local:127.0.0.1 alpine ping 1.local
PING 1.local (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.050 ms
You can have multiple add-host
options in the run
command.
In Docker Compose the equivalent is extra-hosts
:
extra_hosts:
- "1.local:127.0.0.1"
- "2.local:127.0.0.1"
Upvotes: 0