Docker machine timeout - how to fix without destroying the machine?

后端 未结 9 1321
温柔的废话
温柔的废话 2021-01-31 02:47

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

相关标签:
9条回答
  • 2021-01-31 03:22

    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.
    0 讨论(0)
  • 2021-01-31 03:25

    This is usually a problem related to the way you start and stop your machine.

    You can solve it using

    1. $ docker-machine stop default
    2. $ docker-machine start default
    3. $ docker-machine regenerate-certs default

    Do not use docker-machine restart default because it will not refresh your networking configs.

    0 讨论(0)
  • 2021-01-31 03:28

    This worked for me and my containers were not destroyed:

    1. Opened Oracle virtual box and paused the VM
    2. Restarted the VM on docker machine

    $ docker-machine restart default

    • docker version: 1.12.3
    • docker-machine version: 0.8.2, build e18a919
    0 讨论(0)
  • 2021-01-31 03:30

    My problem was very trivial - I did the docker machine ls command right after restarting a docker machine, so it was not running yet, and that caused a timeout.

    0 讨论(0)
  • 2021-01-31 03:31

    My problem was very simple. I was blocking port 2376 with my ufw firewall. Docker-machine needs this port open to connect to the remote.

    I found the answer to my problem in on this page:

    0 讨论(0)
  • 2021-01-31 03:35

    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
    
    0 讨论(0)
提交回复
热议问题