Skip to content

Instantly share code, notes, and snippets.

@kooba
Last active December 20, 2016 17:21
Show Gist options
  • Save kooba/c464f7e33056cb0ad37edcbe43bb0da0 to your computer and use it in GitHub Desktop.
Save kooba/c464f7e33056cb0ad37edcbe43bb0da0 to your computer and use it in GitHub Desktop.
dnspython docker dns issue
version: "2"
services:
test-service:
container_name: test-service
image: busybox
command: ['/bin/sh', '-c', 'sleep 5']
test-client:
container_name: test-client
build: .
dns_search: foo.example.com
FROM python:3.4
RUN pip install dnspython
COPY test.py /var/tmp/test.py
CMD [ "python", "/var/tmp/test.py" ]
import dns.resolver
import socket
service_url = 'test-service'
print('### socket example ###')
ip_list = []
ais = socket.getaddrinfo(service_url, 0, 0, 0, 0)
for result in ais:
ip_list.append(result[-1][0])
ip_list = list(set(ip_list))
print(ip_list[0])
print('### dnspython example ###')
resolver = dns.resolver.Resolver()
answers = resolver.query(service_url)
for data in answers:
print(data.address)
@kooba
Copy link
Author

kooba commented Dec 5, 2016

Gist used for rthalley/dnspython#219

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