-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binding to localhost
inside a container fails because ::1 doesn't exist
#1374
Comments
Any solutions? |
8 tasks
I just ran into the same issue. Just use the local adapter loopback-ip: 127.0.0.1. For some reason localhost resolves to a ipv6 address. I don't know why this is not addressed really. |
@mrdobalina2k Few things to note:
I'm going to close this issue as it's been fixed by moby/moby#47062. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
Programs should be able to safely bind to
localhost
to create listening sockets inside docker. In particularlocalhost
should always resolve to a valid loopback address.Either
::1
should exist as a loopback address or/etc/hosts
should NOT contain a reference to::1 localhost
.Actual behavior
By default (without enabling any IPv6 support) containers have a hosts file (
/etc/hosts
) which looks like this:But it does not add
::1
as an IP address on the loopback device:As a result software attempting to bind to
localhost
and fails becauselocalhost
resolved to::1
and::1
is not an address inside the container.A concrete example; this happens when using python asyncio's
create_server
(manual page). This call should basically never fail, and yet it always fails inside a docker container:Error:
Steps to reproduce the behavior
Output of
docker version
:Output of
docker info
:This was running docker as an AWS ECS instance.
The text was updated successfully, but these errors were encountered: