Docker freezes after MacBook Pro awakes from sleep mode

Expected behavior

Docker is fully functional

Actual behavior

After waking up my MacBook Pro from sleep mode, each docker command (i.e. docker ps) is frozen forever but can be interrupted using Ctrl-C. After exiting Docker for Mac and starting it again, it’s fully functional again.

Information

MacBook Pro (13-inch Mid 2012)
2,9 GHz Intel Core i7
8 GB 1600 MHz DDR3
Macintosh SSD
Intel HD Graphics 4000 1024 MB

OS X: version 10.10.5 (build: 14F1509)
Docker.app: version v1.11.1-beta12
Running diagnostic tests:
[OK] Moby booted
[OK] driver.amd64-linux
[OK] vmnetd
[OK] osxfs
[OK] db
[OK] slirp
[OK] menubar
[OK] environment
[OK] Docker
[OK] VT-x

Steps to reproduce the behavior

  1. Start Docker for Mac
  2. Use docker
  3. Put the mac to sleep for some time
  4. Open the MacBook Pro (wakes it up)
  5. Use docker (i.e. docker ps)

As a work around have you tried using sleepwatcher? There is a known issue with xhyve that causes issues with sleep, I suspect this is the same problem. I work around it by running sleepwatcher (installed from homebrew) with a couple of scripts. In my crontab I have this:

@reboot /usr/local/sbin/sleepwatcher --sleep /Users/ed.silva/scripts/sleep_fix.sh --wake /Users/ed.silva/scripts/wake_fix.sh -d

The sleep.sh script is:

#!/usr/bin/env bash

set -x

eval docker-machine env --shell bash xhyve

for machine in docker ps | grep -v CONTAINER | awk '{print $1}'; do
docker stop $machine
done

docker-machine stop xhyve

The wake script is:

#!/usr/bin/env bash

set -x

docker-machine start xhyve

That keeps the machine from crashing. I’m not sure how to make this work with the docker app, as I just got a hold of it and haven’t seen what I can do yet.