Docker machine timeout - how to fix without destroying the machine?
Solution 1
This command worked for me with the digitalocean driver:
docker-machine ls -t 20
It seems as though the default timeout of 10 seconds was too short.
Solution 2
This is usually a problem related to the way you start and stop your machine.
You can solve it using
$ docker-machine stop default
$ docker-machine start default
$ docker-machine regenerate-certs default
Do not use docker-machine restart default
because it will not refresh your networking configs.
Solution 3
Check if you are are using a proxy or VPN!
None of the above suggestions worked for me until I turned off my VPN and suddenly:
docker-machine.exe ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.102:2376 v19.03.5
Solution 4
I had the same issue with Docker version 1.11.2, build b9f10c9
This worked for me - my docker machine is back to the Running state
$ docker-machine restart
$ eval $(docker-machine env)
Solution 5
So far I have a bit of a hacky solution - this fixes the docker machine but destroys all containers and images.
Script: rebuild-machine.sh
docker-machine rm -y default
docker-machine create -d virtualbox default
docker-machine stop default
VBoxManage modifyvm "default" --natpf1 "Forwarding App 1,tcp,127.0.0.1,3000,,3000"
VBoxManage modifyvm "default" --natpf1 "Forwarding App 2,tcp,127.0.0.1,3001,,3001"
VBoxManage modifyvm "default" --natpf1 "Forwarding App 3,tcp,127.0.0.1,3004,,3004"
VBoxManage modifyvm "default" --natpf1 "Forwarding App 4,tcp,127.0.0.1,3005,,3005"
VBoxManage modifyvm "default" --natpf1 "Forwarding App 5,tcp,127.0.0.1,3006,,3006"
VBoxManage modifyvm "default" --natpf1 "Forwarding App 6,tcp,127.0.0.1,8081,,8081"
docker-machine start default
eval $(docker-machine env)
Explanation
- Destroys the default docker machine, containers and images.
- Creates a new docker machine on VirtualBox and stops it so we can modify VirtualBox.
- Adds port forwarding for various applications on VirtualBox.
- Starts the docker machine.
- Ensures the Terminal is setup for the new IP address of the docker machine.
Josh Cole
Updated on June 07, 2022Comments
-
Josh Cole almost 2 years
I'm having a recurring problem with Docker Machine - every few days it decides to timeout and I am unable to recover it once this happens.
Example
docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default virtualbox Timeout
Environment Info
uname -a Darwin ColeyMBPR 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64 docker version 1.11.0 docker-machine version 0.7.0 vboxmanage --version 5.0.20r106931
Attempted Solutions
I've tried the following things in no particular order:
- Restarting the docker machine.
- Running
eval "$(docker-machine env default)"
- Regenerating the certificates
docker-machine regenerate-certs default
- Restarting my host box.
- Upgrading Docker.
- Reinstalling Docker.
- Upgrading VirtualBox.
- Removing all VirtualBox host-only network devices.
Hack
The only thing that's working for me right now is destroying the docker machine and recreating it. This destroys all my images and containers, and it's incredibly time consuming to set it up again.
docker-machine rm -y default && docker-machine create -d virtualbox default && eval $(docker-machine env)
Is there anything I can try? Thanks!
Update: 9th May (Steps to Reproduce)
I can reliably reproduce this problem with the following steps:
- Start with a freshly created Docker machine.
- Use
docker-compose up
to build some containers. - Shutdown the computer with the containers running.
- After reboot the Docker CLI doesn't work due to the Docker machine timing out.
-
Josh Cole over 7 yearsHi @tej, if you upgrade to the latest version of Docker this is no longer a problem. You no longer need to use Virtual Box at all.
-
Josh Cole about 7 yearsPlease upgrade to the latest version of Docker, this issue was resolved a long time ago.
-
Crystal about 7 yearsi have Docker version 1.13.1, build 092cba3 this problem occurs whenever i put my linux mint to hibernate
-
Ashley Aitken about 7 yearsPity there wasn't an environment variable for this timeout. A pain to have to add every time (or create aliases / shell functions).
-
Richard over 4 yearsdid not work for me but more importantly...stop/start and regen took a long time.
-
Shivansh Jagga almost 4 yearsWhat a lifesave! I had my VPN on and was figuring this out for the last 2 hours!