Answer the question
In order to leave comments, you need to log in
How to configure DNS to work with Docker containers?
There are several Docker containers with php, nginx, mysql of different versions.
To open the site, you need to enter the ID and domain in the hosts.
There is a need to raise the DNS server so that it is responsible for the .dev zone and redirects all requests to the host machine.
In Google, people solved this using dnsmasq, but it doesn’t start for me.
docker-compose.yml config for dns part:
# Версия docker-compose
version: '2'
# Список наших сервисов (контейнеров)
services:
# php nginx mysql #
dns:
build: ./images/dnsmasq
ports:
- "53:53"
- "53:53/udp"
FROM alpine:edge
RUN apk --no-cache add dnsmasq
EXPOSE 53 53/udp
ENTRYPOINT ["dnsmasq", "-k", "-S", "/dev/192.168.99.100"]
Answer the question
In order to leave comments, you need to log in
I do not understand why you need dns. For development, port forwarding from docker is enough and you can work on http://192.168.99.100:port without any problems. To communicate with containers, use api version > 3.0, write your COMPOSE_PROJECT_NAME=test in .env, write net, container db:5432 on the network, then the address will be http://db.test_net:5432.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question