Skip to content

Instantly share code, notes, and snippets.

@paraspatidar
Last active August 25, 2022 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paraspatidar/c29e4adb172a5afc92852a57e621323d to your computer and use it in GitHub Desktop.
Save paraspatidar/c29e4adb172a5afc92852a57e621323d to your computer and use it in GitHub Desktop.
Local dns with wild wildcard dns entries
# explicitly define host-ip mappings
address=/localhost.localstack.cloud/172.16.1.252
# dnsmasq entries are always wildcard entries, so this maps both myapp.local and *.myapp.local
# (yes, it's fine for this to be your entire dnsmasq config. the defaults are pretty sensible)
version: '3.3'
networks:
default:
ipam:
config:
- subnet: 172.16.0.0/23 # In order to specify static IPs, we must explicitly declare subnet.
#ip_range: 172.16.0.0/24 # Range for dynamic IPs. We'll make sure to assign static IPs outside this range.
# docs: https://docs.docker.com/compose/compose-file/compose-file-v2/#ipam
# As of this writing, `ip_range` is not supported in v3, thus we will explictly specify IP
services:
dnsmasq:
image: strm/dnsmasq
volumes:
- './dnsmasq.conf:/etc/dnsmasq.conf' #this file has wildcard dns entries for localstack
ports:
- 53:53/udp
cap_add:
- NET_ADMIN
# dnsmasq container config above is taken verbatim from https://hub.docker.com/r/strm/dnsmasq
networks:
default:
ipv4_address: 172.16.1.253 # Static IP here makes it possible in docker comspose v3 to point other containers' dns here.
localstack:
environment:
- TEST_AWS_ACCOUNT_ID=000000000000
- DEFAULT_REGION=us-east-1
- 'DOCKER_HOST=unix:///var/run/docker.sock'
- HOSTNAME_EXTERNAL=localstack
- HOSTNAME=localstack
privileged: true
container_name: localstack-plat
ports:
- '127.0.0.1:4566:4566'
- '127.0.0.1:4571:4571'
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- 'C:\\tmp:/tmp/localstack'
image: localstack/localstack:0.14.2
networks:
default:
ipv4_address: 172.16.1.252 # Static IP here makes dnsmasq config easy to write and compatible with v3 as v3 dont have range
myclientapp_consuming_localstack:
ports:
- '5030:80'
- '5031:443'
container_name: testapp
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
image: #your-docker-image-goes-here , considering u have put service url for s3 as http://s3.localhost.localstack.cloud:4566
dns:
- 172.16.1.253 # dnsmasq container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment