Last active
December 20, 2016 17:21
-
-
Save kooba/c464f7e33056cb0ad37edcbe43bb0da0 to your computer and use it in GitHub Desktop.
dnspython docker dns issue
This file contains 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: "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 |
This file contains 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
FROM python:3.4 | |
RUN pip install dnspython | |
COPY test.py /var/tmp/test.py | |
CMD [ "python", "/var/tmp/test.py" ] |
This file contains 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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gist used for rthalley/dnspython#219