宿主机系统:Centos7 64位

创建主机实例Virtualbox 命令:docker-machine create -d virtualbox test

连接centos工具:Finalshell 3.9.2.2

(docke疑难杂症,自学笔记)

 


 

错误点1:Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"(如图所示)

 解决方法:

1.在/etc/yum.repos.d/目录下新建virtualbox.repo并写入如下内容

[virtualbox]
name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc

2.更新yum缓存

yum clean all

yum makecache

3.安装virtualbox

yum install VirtualBox-5.1

 

 


 

此时再次运行创建主机实例Virtualbox 命令:docker-machine create -d virtualbox manager,新的错误出现:

错误点2:

Error with pre-create check: "We support Virtualbox starting with version 5. Your VirtualBox install is \"WARNING: The vboxdrv kernel module is not loaded. Either there is no module\\n available for the current kernel (3.10.0-1160.31.1.el7.x86_64) or it failed to\\n load. Please recompile the kernel module and install it by\\n\\n sudo /sbin/vboxconfig\\n\\n You will not be able to start VMs until this problem is fixed.\\n5.1.38r122592\". Please upgrade at https://www.virtualbox.org"

 

 解决方法:

1.检查virtualbox安装配置

输入/sbin/vboxconfig,出现提示:

2.按提示安装核心模块(系统扩展):

yum install gcc make

 

yum install kernel-devel-3.10.0-1160.31.1.e17.x86_64

3.安装完成,验证效果:

 


 

 错误点3:Error with pre-create check: "This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory"

解决方法:

1.poweroff关机后配置虚拟机:

 

 2.开机后,下载boot2docker.iso放在/root/.docker/machine/cache目录下

(boot2docker.iso下载网址https://github.com/boot2docker/boot2docker/releases/)

 

 3.执行docker-machine create -d virtualbox manager命令:

 

 (此时虚拟机内存设置为4G,实际用量达1.4G,刚开始设置1G时运行不起来)

4.创建主机成功后, 可以通过 env 命令来让后续操作对象都是⽬标主机

 docker-machine env test

 

 5.SSH 登录到主机
docker-machine ssh test