Answer the question
In order to leave comments, you need to log in
How to set up a domain in Docker in ngnix through the hosts file ?? How to run it all?
I myself am not very dragged in administration, so I decided to play around with the docker. I assembled the container on this site: https://phptoday.ru/post/gotovim-lokalnuyu-sredu-d... everything worked except for the last point.
I can’t make a domain for the site, that is, the site is available at local ip 127.0.0.1 and localhost, but not at hello.dev. All files and folders are also designed and made as per the instructions in this one, the only thing that was changed by docker-composer is in this part where it primed its hosts file:
services:
nginx:
# используем последний стабильный образ nginx
image: nginx:latest
# маршрутизируем порты
ports:
- "80:80"
- "443:443"
# монтируем директории, слева директории на основной машине, справа - куда они монтируются в контейнере
volumes:
- ./hosts:/etc/nginx/conf.d
- ./hosts/hosts:/etc/hosts
- ./www:/var/www
- ./logs:/var/log/nginx
# nginx должен общаться с php контейнером
links:
- php
127.0.0.1 localhost
127.0.0.1 hello.dev
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.18.0.4 84d108cbe9f9
Answer the question
In order to leave comments, you need to log in
- ./hosts/hosts:/etc/hosts
no need
the host must be registered on the host system in /etc/hosts
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question