sh4 sh4 - 2 months ago 5
PHP Question

Map docker container to regular dev domain name

I'm new to docker, and have recently installed a docker container/image using the (php7, nginx, mysql) generator. Started it using docker-compose and it's working awesome.

If I go to localhost/phpinfo.php my regular system php version loads (5.6), if I go to localhost:8080/phpinfo.php my docker php version loads (7.0) so it's working ok.

My question is: There is any way to map my localhost:8080 to a regular domain name like I normally do with my regular localhost projects? Withouth having to use localhost:8080 i.e.:

Not sure if this is specifically docker related or not.


it is easy. if your nginx config looks like this:

server {
   server_name _; #catch all

you can add to hosts file on you host machine the line

and your container will be available by url<exposed_port>

if you expose you container on 80 port, you can simply type url (like the good old days). But remeber you can run only one container on 80 port at the same time.