if, like me - you’re tired of waiting for responses from your containers running docker for mac, try swapping to docker-machine with nfs mounts!

deps

brew install docker
brew install docker-machine
brew install docker-machine-nfs
brew install go

chose 1 of these:

A: running vmware fusion (even faster than virtualbox)

brew cask install vmware-fusion
go get -u github.com/machine-drivers/docker-machine-driver-vmware
docker-machine create --driver=vmware default

B: default with virtualbox

brew cask install virtualbox
docker-machine create default

enabling NFS mounts (will write to /etc/exports) - can conflict with vagrant/other NFS mounts

docker-machine start default
docker-machine-nfs default

wait for confirmation (restart)

now, let’s do some magic:

add this to your bash-profile:

if which docker-machine > /dev/null; then eval "$(docker-machine env default)"; export DOCKER_MACHINE_IP=$(docker-machine ip default); export DOCKER_HOST_IP=$(sed 's/.\{3\}$/1/' <<< "$(docker-machine ip default)"); fi

reload your shell

exec ${SHELL} -l

add overrides to the existing compose file (emulating docker for mac’s host.docker.internal behavior and allowing applications to see themselves from curl, etc )

touch docker-compose.override.yml

add the following


version: '3'

services:
  httpd:
    extra_hosts:
      - "project.docker.localhost:${DOCKER_MACHINE_IP}"
      - "host.docker.internal:${DOCKER_HOST_IP}"
  php73:
    extra_hosts:
      - "project.docker.localhost:${DOCKER_MACHINE_IP}"
      - "host.docker.internal:${DOCKER_HOST_IP}"

then finally

docker-compose up

and enjoy high-speed mounts and networking

caveat: you’ll either need to set a static host entry for project.docker.localhost on your host machine (macos) or do it with dnsmasq (a howto/automation gude in progress)