Why is my Ruby or ADB network command very slow inside my docker container, but fine for the host?
Recently, two unrelated commands started behaving very poorly inside a Docker container with host-networking:
Android adb took some 12 seconds to connect to another machine's adb server to use its emulators, and Ruby took over 2 minutes to connect to https://rubygems,org.
Both commands normally complete within a fraction of a second, and still do when executed on the container's host machine, or when executed against certain different target servers on the same network.
In particular
ruby -ropen-uri -e 'p open("https://rubygems.org").read'|od -ta |head -2
took 2m12 on Ruby 2.1.2 and timed out after a minute with Ruby 2.5.1.
networking dns ipv6 docker ruby
add a comment |
Recently, two unrelated commands started behaving very poorly inside a Docker container with host-networking:
Android adb took some 12 seconds to connect to another machine's adb server to use its emulators, and Ruby took over 2 minutes to connect to https://rubygems,org.
Both commands normally complete within a fraction of a second, and still do when executed on the container's host machine, or when executed against certain different target servers on the same network.
In particular
ruby -ropen-uri -e 'p open("https://rubygems.org").read'|od -ta |head -2
took 2m12 on Ruby 2.1.2 and timed out after a minute with Ruby 2.5.1.
networking dns ipv6 docker ruby
add a comment |
Recently, two unrelated commands started behaving very poorly inside a Docker container with host-networking:
Android adb took some 12 seconds to connect to another machine's adb server to use its emulators, and Ruby took over 2 minutes to connect to https://rubygems,org.
Both commands normally complete within a fraction of a second, and still do when executed on the container's host machine, or when executed against certain different target servers on the same network.
In particular
ruby -ropen-uri -e 'p open("https://rubygems.org").read'|od -ta |head -2
took 2m12 on Ruby 2.1.2 and timed out after a minute with Ruby 2.5.1.
networking dns ipv6 docker ruby
Recently, two unrelated commands started behaving very poorly inside a Docker container with host-networking:
Android adb took some 12 seconds to connect to another machine's adb server to use its emulators, and Ruby took over 2 minutes to connect to https://rubygems,org.
Both commands normally complete within a fraction of a second, and still do when executed on the container's host machine, or when executed against certain different target servers on the same network.
In particular
ruby -ropen-uri -e 'p open("https://rubygems.org").read'|od -ta |head -2
took 2m12 on Ruby 2.1.2 and timed out after a minute with Ruby 2.5.1.
networking dns ipv6 docker ruby
networking dns ipv6 docker ruby
asked Jan 3 at 9:03
Tim BaverstockTim Baverstock
13
13
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
For the internal servers, someone had allocated IPv6 addresses for them, but not bothered to tell the machine about them, and ADB was working through three IPv6 timeouts before trying IPv4.
For the external addresses, the same someone had allowed DNS to return IPv6 addresses, even though our external router was dropping the packets - same basic principle with timing out with IPv6 before trying IPv4.
The obvious suggestion, turning off IPv6 for the host with the slow commands doesn't work because unfortunately Android ADB finds IPv6 logic in the OS and explodes when the OS says it's unavailable.
My colleague has just pointed out to me that /etc/gai.conf can be used to give IPv4 precedence.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1390092%2fwhy-is-my-ruby-or-adb-network-command-very-slow-inside-my-docker-container-but%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
For the internal servers, someone had allocated IPv6 addresses for them, but not bothered to tell the machine about them, and ADB was working through three IPv6 timeouts before trying IPv4.
For the external addresses, the same someone had allowed DNS to return IPv6 addresses, even though our external router was dropping the packets - same basic principle with timing out with IPv6 before trying IPv4.
The obvious suggestion, turning off IPv6 for the host with the slow commands doesn't work because unfortunately Android ADB finds IPv6 logic in the OS and explodes when the OS says it's unavailable.
My colleague has just pointed out to me that /etc/gai.conf can be used to give IPv4 precedence.
add a comment |
For the internal servers, someone had allocated IPv6 addresses for them, but not bothered to tell the machine about them, and ADB was working through three IPv6 timeouts before trying IPv4.
For the external addresses, the same someone had allowed DNS to return IPv6 addresses, even though our external router was dropping the packets - same basic principle with timing out with IPv6 before trying IPv4.
The obvious suggestion, turning off IPv6 for the host with the slow commands doesn't work because unfortunately Android ADB finds IPv6 logic in the OS and explodes when the OS says it's unavailable.
My colleague has just pointed out to me that /etc/gai.conf can be used to give IPv4 precedence.
add a comment |
For the internal servers, someone had allocated IPv6 addresses for them, but not bothered to tell the machine about them, and ADB was working through three IPv6 timeouts before trying IPv4.
For the external addresses, the same someone had allowed DNS to return IPv6 addresses, even though our external router was dropping the packets - same basic principle with timing out with IPv6 before trying IPv4.
The obvious suggestion, turning off IPv6 for the host with the slow commands doesn't work because unfortunately Android ADB finds IPv6 logic in the OS and explodes when the OS says it's unavailable.
My colleague has just pointed out to me that /etc/gai.conf can be used to give IPv4 precedence.
For the internal servers, someone had allocated IPv6 addresses for them, but not bothered to tell the machine about them, and ADB was working through three IPv6 timeouts before trying IPv4.
For the external addresses, the same someone had allowed DNS to return IPv6 addresses, even though our external router was dropping the packets - same basic principle with timing out with IPv6 before trying IPv4.
The obvious suggestion, turning off IPv6 for the host with the slow commands doesn't work because unfortunately Android ADB finds IPv6 logic in the OS and explodes when the OS says it's unavailable.
My colleague has just pointed out to me that /etc/gai.conf can be used to give IPv4 precedence.
edited Jan 3 at 9:33
answered Jan 3 at 9:08
Tim BaverstockTim Baverstock
13
13
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1390092%2fwhy-is-my-ruby-or-adb-network-command-very-slow-inside-my-docker-container-but%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown