In my hosts file I have only the following following domains:
127.0.0.1 localhost
127.0.0.1 abc.com
When I run the image I use the following command: docker run -p 80:80 -v /Users/userName/Documents/siteABC:/var/www/html my_image
. I can type in the URL abc.com
or localhost
and the site works using the docker server, as expected.
I was wondering if there is any way to dynamically build the host when I squeeze the docker image.
Example I would like to be able to type in the URL abcphp56.com
without having to create this domain in my /etc/hosts
.
According to this post , if I understood correctly, run the image with the following command: docker run -p 80:80 --add-host abcphp56.com:127.0.0.1 -v /Users/userName/Documents/siteABC:/var/www/html my_image
and I would have the system responsive to the 3 domains: localhost , abc.com and abcphp56.com >, but it is not working.
How could I do this?