-
-
Save mattbaker/e1aaa66be03c11f69649fded0d931107 to your computer and use it in GitHub Desktop.
Example reproduction of DNS caching 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
# Create a docker network named 'frontend' | |
$ docker network create frontend | |
# Start several aliased containers that will be part of the round-robin | |
$ docker run -d --net frontend --net-alias example.test nginx:alpine | |
$ docker run -d --net frontend --net-alias example.test nginx:alpine | |
$ docker run -d --net frontend --net-alias example.test nginx:alpine | |
$ docker run -d --net frontend --net-alias example.test nginx:alpine | |
$ docker run -d --net frontend --net-alias example.test nginx:alpine | |
# Run an elixir container on the network without caching enabled, | |
# where inetrc file contains: | |
# | |
# {lookup, [dns, native]}. | |
# {cache_size, 100}. | |
# {cache_refresh, 60}. | |
# | |
$ docker run --rm -it -v $(pwd)/inetrc:/inetrc --net frontend elixir iex | |
iex(1)> Enum.map(0..4, fn _ -> :inet.getaddrs('example.test', :inet) end) | |
[ | |
ok: [ | |
{172, 18, 0, 4}, | |
{172, 18, 0, 3}, | |
{172, 18, 0, 5}, | |
{172, 18, 0, 2}, | |
{172, 18, 0, 6} | |
], | |
ok: [ | |
{172, 18, 0, 4}, | |
{172, 18, 0, 6}, | |
{172, 18, 0, 3}, | |
{172, 18, 0, 5}, | |
{172, 18, 0, 2} | |
], | |
ok: [ | |
{172, 18, 0, 2}, | |
{172, 18, 0, 3}, | |
{172, 18, 0, 6}, | |
{172, 18, 0, 4}, | |
{172, 18, 0, 5} | |
], | |
ok: [ | |
{172, 18, 0, 4}, | |
{172, 18, 0, 6}, | |
{172, 18, 0, 3}, | |
{172, 18, 0, 5}, | |
{172, 18, 0, 2} | |
], | |
ok: [ | |
{172, 18, 0, 4}, | |
{172, 18, 0, 3}, | |
{172, 18, 0, 6}, | |
{172, 18, 0, 2}, | |
{172, 18, 0, 5} | |
] | |
] | |
# Run an elixir container on the network with caching enabled | |
# After the initial lookup subsequent lookups return the list sorted | |
$ docker run --rm -it -v $(pwd)/inetrc:/inetrc --net frontend elixir iex --erl "-kernel inetrc '/inetrc'" | |
iex(1)> Enum.map(0..4, fn _ -> :inet.getaddrs('example.test', :inet) end) | |
[ | |
ok: [ | |
{172, 18, 0, 2}, | |
{172, 18, 0, 3}, | |
{172, 18, 0, 4}, | |
{172, 18, 0, 6}, | |
{172, 18, 0, 5} | |
], | |
ok: [ | |
{172, 18, 0, 2}, | |
{172, 18, 0, 3}, | |
{172, 18, 0, 4}, | |
{172, 18, 0, 5}, | |
{172, 18, 0, 6} | |
], | |
ok: [ | |
{172, 18, 0, 2}, | |
{172, 18, 0, 3}, | |
{172, 18, 0, 4}, | |
{172, 18, 0, 5}, | |
{172, 18, 0, 6} | |
], | |
ok: [ | |
{172, 18, 0, 2}, | |
{172, 18, 0, 3}, | |
{172, 18, 0, 4}, | |
{172, 18, 0, 5}, | |
{172, 18, 0, 6} | |
], | |
ok: [ | |
{172, 18, 0, 2}, | |
{172, 18, 0, 3}, | |
{172, 18, 0, 4}, | |
{172, 18, 0, 5}, | |
{172, 18, 0, 6} | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment