I am just learning the ropes with Docker, however one thing seems to of stumped me. I have tried to find answers to my question elsewhere (add entry to host /etc/hosts file when a docker container is started) but none really seemed to solve my question.
I am using docker-compose version 2 and docker-compose.yml
looks like this:
version: "2"
services:
web:
image: php:5-apache
extra_hosts:
- "example.com:127.0.0.1"
ports:
- "80"
command: php -S 0.0.0.0:80 -t /var/www/html
working_dir: /var/www/html
restart: always
I want to be able to go to example.com
on the host machine and have it point to the docker container. Also, it seems like docker containers IP's can change on restart? Is there a way to keep track of the IP even after restart?
I guess what I am after is similar to: https://github.com/cogitatio/vagrant-hostsupdater