Skip to content

Instantly share code, notes, and snippets.

@comm1x
Last active October 22, 2018 15:53
Show Gist options
  • Save comm1x/3bd41485b6edb337f71492b3d5f0db04 to your computer and use it in GitHub Desktop.
Save comm1x/3bd41485b6edb337f71492b3d5f0db04 to your computer and use it in GitHub Desktop.
Docker DNS workaround

Docker DNS workaround

1. Run docker container, which will resolve inner containers

version: '2'
services:
  dns-gen:
    container_name: dns-gen 
    image: jderusse/dns-gen
    ports:
      - "127.0.0.1:54:53/udp"
    restart: unless-stopped
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"

2. Install and configure dnsmasq to forward requests

apt install dnsmasq

Add custom config to /etc/dnsmasq.d/my-dns-gen.conf

server=/.docker/127.0.0.1#54 

That's all. Containers will resolve by CONTAINER_NAME.docker. Also you can specify DOMAIN_NAME env. Dns-gen container: https://github.com/jderusse/docker-dns-gen

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