背景说明
Docker Machine是一种可以让您在虚拟主机上安装 Docker 的工具,并可以使用 docker-machine 命令来管理主机。
解决方案
文件下载
[root@vm1 ~]# curl -L https://github.com/docker/machine/releases/download/v0.16.2/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine[root@vm1 ~]# chmod +x /tmp/docker-machine[root@vm1 ~]# sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
版本查看
[root@vm1 ~]# docker-machine versiondocker-machine version 0.16.2, build bd45ab13[root@vm1 ~]#
驱动安装
尝试执行主机创建命令,发现缺失驱动VBoxManage
[root@vm1 ~]# docker-machine create --driver virtualbox myvm1Running pre-create checks...Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"[root@vm1 ~]# yum install virtualboxLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile* base: mirrors.aliyun.com* epel: mirrors.bfsu.edu.cn* extras: mirrors.aliyun.com* updates: mirrors.aliyun.comNo package virtualbox available.Error: Nothing to do
创建仓库Repo文件/etc/yum.repos.d/virtualbox.repo
[root@vm1 ~]# cd /etc/yum.repos.d/[root@vm1 yum.repos.d]# touch virtualbox.repo[root@vm1 yum.repos.d]# vim virtualbox.repo
文件内容如下
[virtualbox]name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBoxbaseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearchenabled=1gpgcheck=1repo_gpgcheck=1gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
也可以通过命令直接下载: wget http://downlo[ad](https://dfm.elecfans.com/uploads/software/hqdfm.zip?neilian).virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
执行仓库更新
[root@vm1 yum.repos.d]# yum clean allLoaded plugins: fastestmirrorCleaning repos: base docker-ce-stable epel extras updates virtualboxCleaning up list of fastest mirrors[root@vm1 yum.repos.d]# yum makecacheLoaded plugins: fastestmirror
安装驱动
[root@vm1 yum.repos.d]# yum install -y VirtualBox-5.1
此时执行创建发现仍然出现错误
[root@vm1 yum.repos.d]# docker-machine create -d virtualbox managerRunning pre-create checks...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-957.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"
执行/sbin/vboxconfig检查virtualbox安装配置
[root@vm1 yum.repos.d]# /sbin/vboxconfigvboxdrv.sh: Stopping VirtualBox services.vboxdrv.sh: Building VirtualBox kernel modules.This system is not currently set up to build kernel modules (system extensions).Running the following commands should set the system up correctly:yum install gcc makeyum install kernel-devel-3.10.0-957.el7.x86_64(The last command may fail if your system is not fully updated.)yum install kernel-develvboxdrv.sh: failed: Look at /var/log/vbox-install.log to find out what went wrong.This system is not currently set up to build kernel modules (system extensions).Running the following commands should set the system up correctly:yum install gcc makeyum install kernel-devel-3.10.0-957.el7.x86_64(The last command may fail if your system is not fully updated.)yum install kernel-develThere were problems setting up VirtualBox. To re-start the set-up process, run/sbin/vboxconfigas root.
按照如上命令进行安装https://mirror.nsc.liu.se/centos-store/7.6.1810/isos/x86_64/目录下的CentOS-7-x86_64-DVD-1810.iso
[root@vm1 yum.repos.d]# yum install -y gcc make[root@vm1 ~]# rpm -ivh kernel-devel-3.10.0-957.el7.x86_64.rpm
再次执行创建命令,仍然报错
[root@vm1 ~]# docker-machine create -d virtualbox manageRunning pre-create checks...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-957.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"
再次执行命令/sbin/vboxconfig
[root@vm1 ~]# /sbin/vboxconfigvboxdrv.sh: Stopping VirtualBox services.vboxdrv.sh: Building VirtualBox kernel modules.vboxdrv.sh: Starting VirtualBox services.
再次执行创建命令,仍然报错
[root@vm1 ~]# docker-machine create -d virtualbox manageRunning pre-create checks...Error with pre-create check: "This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory"[root@vm1 ~]#
关闭虚拟机,并调整虚拟机配置
再次开启机器






彻底关闭 Hyper-V 服务
右键开始图标打开“Windows PowerShell (管理员)(A)”
在 Windows PowerShell 执行命令:bcdedit /set hypervisorlaunchtype off
部署验证
此时再次创建,正常执行
[root@vm1 ~]# docker-machine create -d virtualbox manageRunning pre-create checks...Creating machine...(manage) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/manage/boot2docker.iso...(manage) Creating VirtualBox VM...(manage) Creating SSH key...(manage) Starting the VM...(manage) Check network to re-create if needed...(manage) Found a new host-only adapter: "vboxnet0"(manage) Waiting for an IP...
查看主机和版本
[root@vm1 ~]# docker-machine lsNAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORSmanage - virtualbox Running tcp://192.168.99.100:2376 v19.03.12[root@vm1 ~]#[root@vm1 ~]# docker-machine ssh manage( '>')/) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY.(/-_--_-\) www.tinycorelinux.netdocker@manage:~$ docker versionClient: Docker Engine - CommunityVersion: 19.03.12API version: 1.40Go version: go1.13.10Git commit: 48a66213feBuilt: Mon Jun 22 15:42:53 2020OS/Arch: linux/amd64Experimental: falseServer: Docker Engine - CommunityEngine:Version: 19.03.12API version: 1.40 (minimum version 1.12)Go version: go1.13.10Git commit: 48a66213feBuilt: Mon Jun 22 15:49:35 2020OS/Arch: linux/amd64Experimental: falsecontainerd:Version: v1.2.13GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429runc:Version: 1.0.0-rc10GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dddocker-init:Version: 0.18.0GitCommit: fec3683docker@manage:~$
[
