docksal: host.docker.internal not working

When using docksal with Docker for Mac, it seems that host.docker.internal (documented here: https://docs.docker.com/docker-for-mac/networking/) doesn’t work.

Steps to reproduce the issue:

  1. Install docksal and init new project using the default stack as per the official docksal documentation.
  2. docker exec -it [WEB_CONTAINER] sh
  3. then inside the container run: ping host.docker.internal

Results: ping: bad address 'host.docker.internal'

Expected results:

PING host.docker.internal (192.168.65.2): 56 data bytes
64 bytes from 192.168.65.2: seq=0 ttl=37 time=1.007 ms
64 bytes from 192.168.65.2: seq=1 ttl=37 time=0.357 ms
...

I have tested the same ping in another container that is not created by docksal just to check if there is a problem with my local docker instance, and it’s working there as expected.

Output of fin config:

fin config output
/var/www # berliner-mac:test-site berliner$ fin config
---------------------
COMPOSE_PROJECT_NAME_SAFE: test-site
COMPOSE_FILE:
/Users/berliner/.docksal/stacks/overrides-osxfs.yml
/Users/berliner/.docksal/stacks/volumes-bind.yml
/Users/berliner/.docksal/stacks/stack-default.yml
/Users/berliner/Projects/test-site/.docksal/docksal.yml
ENV_FILE:
/Users/berliner/Projects/test-site/.docksal/docksal.env
/Users/berliner/Projects/test-site/.docksal/docksal-local.env

PROJECT_ROOT: /Users/berliner/Projects/test-site
DOCROOT: html
VIRTUAL_HOST: test-site.docksal
VIRTUAL_HOST_ALIASES: *.test-site.docksal
IP: 192.168.64.100
MYSQL: 192.168.64.100:3312

Docker Compose configuration
---------------------
services:
  cli:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      BLACKFIRE_CLIENT_ID: null
      BLACKFIRE_CLIENT_TOKEN: null
      DOCROOT: html
      DRUSH_ALLOW_XDEBUG: '0'
      GIT_USER_EMAIL: null
      GIT_USER_NAME: null
      HOST_GID: '20'
      HOST_UID: '501'
      PHP_IDE_CONFIG: serverName=test-site.docksal
      SECRET_ACAPI_EMAIL: null
      SECRET_ACAPI_KEY: null
      SECRET_PLATFORMSH_CLI_TOKEN: null
      SECRET_SSH_PRIVATE_KEY: null
      SECRET_TERMINUS_TOKEN: null
      VIRTUAL_HOST: test-site.docksal
      XDEBUG_CONFIG: remote_connect_back=0 remote_host=192.168.64.1
      XDEBUG_ENABLED: '0'
    hostname: cli
    image: docksal/cli:2.6-php7.2
    volumes:
    - docksal_ssh_agent:/.ssh-agent:ro
    - cli_home:/home/docker:rw
    - /Users/berliner/Projects/test-site:/var/www:rw,cached
  db:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: null
      MYSQL_DATABASE: default
      MYSQL_INITDB_SKIP_TZINFO: null
      MYSQL_ONETIME_PASSWORD: null
      MYSQL_PASSWORD: user
      MYSQL_RANDOM_ROOT_PASSWORD: null
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: user
    hostname: db
    image: docksal/mysql:5.6-1.4
    ports:
    - 3312:3306/tcp
    volumes:
    - db_data:/var/lib/mysql:rw
    - project_root:/var/www:ro,nocopy
  web:
    depends_on:
      cli:
        condition: service_started
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      APACHE_BASIC_AUTH_PASS: null
      APACHE_BASIC_AUTH_USER: null
      APACHE_DOCUMENTROOT: /var/www/html
      APACHE_FCGI_HOST_PORT: cli:9000
    hostname: web
    image: docksal/apache:2.4-2.3
    labels:
      io.docksal.cert-name: none
      io.docksal.permanent: "false"
      io.docksal.project-root: /Users/berliner/Projects/test-site
      io.docksal.virtual-host: test-site.docksal,*.test-site.docksal,test-site.docksal.*
    volumes:
    - project_root:/var/www:ro,nocopy
version: '2.1'
volumes:
  cli_home: {}
  db_data: {}
  docksal_ssh_agent:
    external: true
    name: docksal_ssh_agent
  project_root:
    driver: local
    driver_opts:
      device: /Users/berliner/Projects/test-site
      o: bind
      type: none

---------------------

Output of fin sysinfo:

fin sysinfo output
███  OS
Darwin Mac OS X 10.14.6
Darwin berliner-mac.local 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64

███  ENVIRONMENT
MODE : Docker Desktop

███  FIN
fin version: 1.86.2

███  DOCKER COMPOSE
EXPECTED VERSION: 1.23.2
docker-compose version 1.23.2, build 1110ad01
docker-py version: 3.6.0
CPython version: 3.6.6
OpenSSL version: OpenSSL 1.1.0h  27 Mar 2018

███  DOCKER
EXPECTED VERSION: 18.09.2

Client: Docker Engine - Community
Version:           18.09.2
API version:       1.39
Go version:        go1.10.8
Git commit:        6247962
Built:             Sun Feb 10 04:12:39 2019
OS/Arch:           darwin/amd64
Experimental:      false

Server: Docker Engine - Community
Engine:
Version:          19.03.2
API version:      1.40 (minimum version 1.12)
Go version:       go1.12.8
Git commit:       6a30dfc
Built:            Thu Aug 29 05:32:21 2019
OS/Arch:          linux/amd64
Experimental:     false
containerd:
Version:          v1.2.6
GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version:          1.0.0-rc8
GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
docker-init:
Version:          0.18.0
GitCommit:        fec3683

███  DOCKSAL: PROJECTS
project             STATUS                    virtual host                                                      project root
test-site         Up 22 minutes (healthy)   test-site.docksal,*.test-site.docksal,test-site.docksal.*   /Users/berliner/Projects/test-site

███  DOCKSAL: VIRTUAL HOSTS
*.test-site.docksal
test-site.docksal.*
test-site.docksal

███  DOCKSAL: DNS
Successfully requested http://dns-test.docksal

███  DOCKER: RUNNING CONTAINERS
CONTAINER ID        IMAGE                                         COMMAND                  CREATED             STATUS                    PORTS                                                    NAMES
d7e5db1ae06f        docksal/apache:2.4-2.3                        "httpd-foreground"       22 minutes ago      Up 22 minutes (healthy)   80/tcp, 443/tcp                                          test-site_web_1
094996fafdab        docksal/ssh-agent:1.2                         "docker-entrypoint.s…"   2 hours ago         Up 2 hours (healthy)                                                               docksal-ssh-agent
5cfcb0422a8c        docksal/dns:1.1                               "docker-entrypoint.s…"   2 hours ago         Up 2 hours (healthy)      192.168.64.100:53->53/udp                                docksal-dns
8f63212f51a8        docksal/vhost-proxy:1.5                       "docker-entrypoint.s…"   2 hours ago         Up 2 hours (healthy)      192.168.64.100:80->80/tcp, 192.168.64.100:443->443/tcp   docksal-vhost-proxy
3d747fe5f0e9        docksal/mysql:5.6-1.4                         "docker-entrypoint.s…"   2 weeks ago         Up 2 hours (healthy)      0.0.0.0:3312->3306/tcp                                   test-site_db_1
8812585557e8        docksal/cli:2.6-php7.2                        "/opt/startup.sh sup…"   2 weeks ago         Up 2 hours (healthy)      22/tcp, 3000/tcp, 9000/tcp                               test-site_cli_1

███  DOCKER: NETWORKS
NETWORK ID          NAME                      DRIVER              SCOPE
130eb884b1e3        _default                  bridge              local
defba65814aa        bridge                    bridge              local
c68b5f26df82        test-site_default       bridge              local
f677e28f42e6        host                      host                local
10a219d07e5c        none                      null                local

███  DOCKER DESKTOP
EXPECTED VERSION: 2.0.0.3
2.1.0.2

███  HDD Usage
Filesystem      Size   Used  Avail Capacity iused               ifree %iused  Mounted on
/dev/disk1s1   466Gi  438Gi   26Gi    95% 4696469 9223372036850079338    0%   /
devfs          332Ki  332Ki    0Bi   100%    1148                   0  100%   /dev
/dev/disk1s4   466Gi  1.0Gi   26Gi     4%       1 9223372036854775806    0%   /private/var/vm
map -hosts       0Bi    0Bi    0Bi   100%       0                   0  100%   /net
map auto_home    0Bi    0Bi    0Bi   100%       0                   0  100%   /home

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 4
  • Comments: 16 (10 by maintainers)

Most upvoted comments

Great, happy to see that the underlying problem of this issue is clear now. Looking forward for 1.14 then. Great project btw!!