Skip to content
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

use something else other than .localhost at the end of docker.for.mac.localhost #1837

Closed
andrewchen5678 opened this issue Jul 7, 2017 · 11 comments

Comments

@andrewchen5678
Copy link

Expected behavior

docker.for.mac.localhost works on guest's Chrome browser

Actual behavior

docker.for.mac.localhost doesn't work on Chrome because .localhost is strictly reserved for local ips and Chrome won't try to resolve the hostname

Suggestion

Use something else other than .localhost for tld for the special Mac-only DNS name docker.for.mac.localhost because .localhost is supposed to be reserved for local only traffic. See https://en.wikipedia.org/wiki/.localhost

@speigg
Copy link

speigg commented Jul 15, 2017

I'm seeing this problem too. How about docker.for.mac.local... or just docker.local ?

@atuttle
Copy link

atuttle commented Oct 16, 2017

A container-internal hostname that is dependent on the host OS is the wrong solution. If I write code that depends on there being a docker.for.mac.localhost host available, then hand that container over to a linux or windows user, it will not function properly. A cross-platform solution is necessary.

@dchevell
Copy link

Agreed @atuttle, some kind of docker.host.local solution is needed

@jtneal
Copy link

jtneal commented Oct 19, 2017

This also isn't working for me. Anything .localhost in my container resolves to 127.0.0.1 - localhost of the container, not the IP of the host machine.

docker exec -it my_container getent ahosts docker.for.mac.localhost
127.0.0.1

docker exec -it my_container getent ahosts whatever.i.want.localhost
127.0.0.1

@cllovatto
Copy link

cllovatto commented Nov 28, 2017

If someone hasn't come across it yet, a workaround would be to use IP address 192.168.65.1
This resolves to the mac host.
Original post:
moby/moby#22753 (comment)

@HaysHopkins
Copy link

I'm not seeing any question quite like this and this seems as good of a place as any to ask, so:

I can ping docker.for.mac.localhost and 192.168.65.1 just fine. I know my non-docker service is running there just fine. I can reach it at localhost.mywebsite.com:9999 in chrome just fine. However, I can't just do docker.for.mac.localhost.mywebsite.com:9999.

It's driving me crazy! Any suggestions to reach this address? (changing it is not an option for me)

@atuttle
Copy link

atuttle commented Nov 30, 2017

@HaysHopkins unless you've setup DNS or a hosts file entry for that address, you shouldn't expect it to work. You can configure the website to respond for docker.for.mac.localhost in addition to localhost.mywebsite.com or make it reply with your website regardless of the domain name (i.e. the default if no host match is found) ~~ e.g. anything hitting port 9999 gets your website regardless of hostname. This is the default setup in most cases if only one website is being served by the server.

If you can't ping docker.for.mac.localhost.mywebsite.com from inside the container then the request will never leave the container.

@aleksandrs-ledovskis
Copy link

This issue has been fixed in 17.12.0-ce-mac46 release

@atuttle
Copy link

atuttle commented Jan 17, 2018

"Fixed" is arguable as the container still needs to know that it's running on docker for mac; as noted in October.

@pgayvallet
Copy link

Using docker.for.mac.host.internal fixes the author issue.

Discussions about how a container should know if it should interract with the effective host (mac) or the actual host (vm) is out of the scope.

Closing

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests