Skip to content

Instantly share code, notes, and snippets.

@boomshadow
Forked from NAR8789/dnsmasq.conf
Last active April 18, 2024 20:11
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boomshadow/20677ef02f110e448ee058ae6149af3a to your computer and use it in GitHub Desktop.
Save boomshadow/20677ef02f110e448ee058ae6149af3a to your computer and use it in GitHub Desktop.
wildcard dns for docker-compose using dnsmasq
# explicitly define host-ip mappings
# dnsmasq entries are always wildcard entries, so this maps both myapp.local and *.myapp.local
address=/myapp.local/219.219.219.125
# set the upstream resolver for people running Linux; this allows all other DNS to be resolved:
server=1.1.1.1
server=1.0.0.1
version: '3.9'
networks:
my_network:
ipam:
config:
- subnet: 219.219.219.64/26 # In order to specify static IPs, we must explicitly declare the subnet
services:
dnsmasq:
image: strm/dnsmasq
volumes:
- ./dnsmasq.conf:/etc/dnsmasq.conf
cap_add:
- NET_ADMIN
networks:
my_network:
ipv4_address: 219.219.219.126
myapp:
# ...
# your app config here
# ...
networks:
my_network:
# Set a static IP for dnsmasq config. This will allow us to wildcard catch all our sub-domains.
ipv4_address: 219.219.219.125
appclient:
# ...
# more container config
# ...
networks:
- my_network
dns:
- 219.219.219.126 # dnsmasq container
# `appclient` should now be able to access `myapp` as myapp.local or foo.myapp.local
@boomshadow
Copy link
Author

A docker compose v3 compliant version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment