-
-
Save boomshadow/20677ef02f110e448ee058ae6149af3a to your computer and use it in GitHub Desktop.
wildcard dns for docker-compose using dnsmasq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A docker compose v3 compliant version.