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

后端 未结 9 1325
温柔的废话
温柔的废话 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.

提交回复
热议问题