更新: Boot2Docker 现在是旧版。有关官方弃用通知,请参见此处:https : //docs.docker.com/installation/mac/,有关将预先存在的 Boot2Docker vm 迁移到 Docker Machine 的信息,请参见此处: https ://docs.docker.com/machine/migrate-到机器/ .
我还没有看到这个问题是否继续存在,或者是否有类似的解决方案,docker-machine
使用适当的标志代替运行boot2docker
,将有助于解决它。
这对我有用,我保留了所有图像/容器。我关注了 Anthony A 的回复:https ://stackoverflow.com/a/26592419/4377364 。
以下是具体步骤:
$ boot2docker -v info
{
"Name": "boot2docker-vm",
"UUID": "470abff4-f4fe-4c24-90c5-32b3ef7bfbe2",
"Iso": "/Users/pat/.boot2docker/boot2docker.iso",
"State": "saved",
"CPUs": 4,
"Memory": 2048,
"VRAM": 8,
"CfgFile": "/Users/pat/VirtualBox VMs/boot2docker-vm/boot2docker-vm.vbox",
"BaseFolder": "/Users/pat/VirtualBox VMs/boot2docker-vm",
"OSType": "",
"Flag": 0,
"BootOrder": null,
"DockerPort": 0,
"SSHPort": 2022,
"SerialFile": "/Users/pat/.boot2docker/boot2docker-vm.sock"
}
注意: "State": "saved"
。
识别 .vbox 文件:
"CfgFile": "/Users/pat/VirtualBox VMs/boot2docker-vm/boot2docker-vm.vbox"
将此用作启动 VM 的输入:
$ VBoxManage startvm "/Users/pat/VirtualBox VMs/boot2docker-vm/boot2docker-vm.vbox"
然后关闭它:
$ VBoxManage controlvm "/Users/pat/VirtualBox VMs/boot2docker-vm/boot2docker-vm.vbox" acpipowerbutton
验证它实际上已关闭:
$ boot2docker -v info
{
"Name": "boot2docker-vm",
"UUID": "470abff4-f4fe-4c24-90c5-32b3ef7bfbe2",
"Iso": "/Users/pat/.boot2docker/boot2docker.iso",
"State": "poweroff",
"CPUs": 4,
"Memory": 2048,
"VRAM": 8,
"CfgFile": "/Users/pat/VirtualBox VMs/boot2docker-vm/boot2docker-vm.vbox",
"BaseFolder": "/Users/pat/VirtualBox VMs/boot2docker-vm",
"OSType": "",
"Flag": 0,
"BootOrder": null,
"DockerPort": 0,
"SSHPort": 2022,
"SerialFile": "/Users/pat/.boot2docker/boot2docker-vm.sock"
}
注意: "State": "poweroff"
。
启动 boot2docker 虚拟机:
$ boot2docker up
Waiting for VM and Docker daemon to start...
.................ooo
Started.