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

1
2
3
4
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)

1
2
3
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

1
2
brew cask install virtualbox
docker-machine create default

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

1
2
docker-machine start default
docker-machine-nfs default

wait for confirmation (restart)

now, let’s do some magic:

add this to your bash-profile:

1
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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13

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

1
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)