linux下安装docker-machine
首先下载二进制文件 wget https://github.com/docker/machine/releases/download/v0.13.0/docker-machine-Linux-x86_64 接着修改可执行权限 chmod +x docker-machine-Linux-x86_64
最后移动二进制文件到/usr/local/bin/目录下 cp docker-machine-Linux-x86_64 /usr/local/bin/docker-machine
最后在命令行下测试下是不是可以使用了 docker-machine -v
记住官网下https://docs.docker.com/machine/install-machine/#install-machine-directly
注意
[root@yanglin1 ~]# docker-machine create demo1 Running pre-create checks... Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"
报错提示没有发现VBoxManage。因此,需要手工安装,具体安装操作如下。
[root@master ~]# vim /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=0
repo_gpgcheck=0
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
[root@master ~]# yum search VirtualBox #查找具体安装版本
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* epel: mirrors.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
============== N/S matched: VirtualBox ===================================
VirtualBox-4.3.x86_64 : Oracle VM VirtualBox
VirtualBox-5.0.x86_64 : Oracle VM VirtualBox
VirtualBox-5.1.x86_64 : Oracle VM VirtualBox
VirtualBox-5.2.x86_64 : Oracle VM VirtualBox
[root@master ~]# yum install -y VirtualBox-5.2 #安装
[root@master ~]# /sbin/vboxconfig #重新加载virtualbox服务
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-693.el7.x86_64
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-693.el7.x86_64
There were problems setting up VirtualBox. To re-start the set-up process, run
/sbin/vboxconfig
as root.
#如果内核版本不一致,会出现上面的报错,需要安装相同的内核版本
[root@master ~]# rpm -ivh kernel-devel-3.10.0-693.el7.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:kernel-devel-3.10.0-693.el7 ################################# [100%]
[root@slave1 ~]# yum install gcc make perl -y
[root@slave1 ~]# rpm -qa kernel\*
kernel-tools-3.10.0-693.el7.x86_64
kernel-devel-3.10.0-693.el7.x86_64
kernel-tools-libs-3.10.0-693.el7.x86_64
kernel-3.10.0-693.el7.x86_64
kernel-headers-3.10.0-862.3.2.el7.x86_64
[root@slave1 ~]# /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: Starting VirtualBox services.
[root@centos7 ~]# docker-machine create --driver virtualbox testhost
Running 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@centos7 ~]# docker-machine create --driver virtualbox default
Running pre-create checks...
(default) No default Boot2Docker ISO found locally, downloading the latest release...
(default) Latest release for github.com/boot2docker/boot2docker is v18.05.0-ce
(default) Downloading /root/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v18.05.0-ce/boot2docker.iso...
(default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(default) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/default/boot2docker.iso...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting the VM...
(default) Check network to re-create if needed...
(default) Found a new host-only adapter: "vboxnet0"
(default) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env default
#可以先安装个默认的虚拟机
[root@centos7 ~]# docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Running tcp://192.168.99.100:2376 v18.05.0-ce
[root@centos7 ~]# docker-machine status
Running
原文:https://www.cnblogs.com/hbxZJ/p/10805895.html