Docker unreachable after computer sleep

Klas Mellbourn picture Klas Mellbourn · Sep 13, 2015 · Viewed 7.9k times · Source

I have just installed docker using docker-toolbox 1.8.2 on Windows 10.

Due to due to this issue I had to recreate the docker image using these commands

docker-machine rm default
docker-machine --native-ssh create -d virtualbox default

After that it has been working fine, except for one problem:

When the PC has gone to sleep and then wakes again, the docker commands can no longer connect. Example:

> docker images
An error occurred trying to connect: Get https://192.168.99.100:2376/v1.20/images/json: 
dial tcp 192.168.99.100:2376: ConnectEx tcp: A connection attempt failed because the 
connected party did not properly respond after a period of time, or established connection 
failed because connected host has failed to respond.

However the docker-machine lists the machine as running:

> docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM
default   *        virtualbox   Running   tcp://192.168.99.100:2376

I can also confirm in VirtualBox that the VM screen seems to be active.

I have tried starting and stopping the machine, but that does not help

C:\x> docker-machine stop default
C:\x> docker-machine start default
Starting VM...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
C:\x> docker-machine env default --shell=powershell

Ironically, the last command hangs, so I never get any environment settings.

The only thing that helps is to restart the whole PC. But that should be unnecessary?

I have also posted this as an issue on the docker github repository,but that was closed. A related issue seems to be this one, but no workaround or solution has been posted for Windows.

Answer

Dzoukr picture Dzoukr · Oct 8, 2015

After hous of fighting with VirtualBox + Docker Toolbox, I finally found the way, how to make Docker working again (even without restarting all the containers):

  1. Wake up PC from sleep
  2. Try docker images (won`t work)
  3. Open VirtualBox -> Close VM with saving state (CTRL+V)
  4. Run your VM again
  5. Try docker images again (now should work)

Please note: All steps are in VirtualBox only! Running docker-machine restart default will create another host-only adapter, which is something you do not want. If you did it anyway, delete all additionally created adapters (File->Preferences->Network on VirtualBox), then follow steps 1-5.