我是靠谱客的博主 娇气芒果,最近开发中收集的这篇文章主要介绍Docker Machine,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

docker三剑客

GITEE映射的GITHUB的Docker-Machine的地址

Docker machine搭建遇到的问题:Error with pre-create check: “VBoxManage not found. Make sure VirtualBox is

docker machine

写的很不错 

1.简介

Docker Machine是Docker官方三剑客项目之一,负责使用Docker的第一步,在多种平台上快速安装Docker环境。它支持多种平台,让用户可以在很短时间内搭建一套Docker主机集群。

Machine项目主要由Go编写,用户可以在本地任意指定被Machine管理的Docker主机,并对其进行操作。Machine定位是“在本地或者云环境中创建Docker主机(Create Docker hosts on your computer,on cloud providers,and inside your own data center.)”。

其基本功能包括:

·在指定节点上安装Docker引擎,配置其为Docker主机;

·集中管理所有Docker主机。

Machine连接不同类型的节点是通过不同驱动指定的,目前已经支持了包括IBM、Amazon、Google等多家数据中心的云主机。

2.安装

base=https://github.com/docker/machine/releases/download/v0.16.0 &&   curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine &&   sudo mv /tmp/docker-machine /usr/local/bin/docker-machine &&   chmod +x /usr/local/bin/docker-machine

3.通过VirtualBox来创建的例子

3.1 报错VBoxManage not found

Make sure VirtualBox is installed and VBoxManage is in the path

安装virtualbox

3.2 This computer doesn't have VT-X/AMD-v enabled.

[root@wknode doc]# docker-machine create --driver=virtualbox vbox-instance
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"

解决方案:

3.3 成功创建一个虚拟机器并为其安装docker环境

[root@wknode muten003]# docker-machine create --driver=virtualbox  vbox-instance
Running pre-create checks...
Creating machine...
(vbox-instance) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/vbox-instance/boot2docker.iso...
(vbox-instance) Creating VirtualBox VM...
(vbox-instance) Creating SSH key...
(vbox-instance) Starting the VM...
(vbox-instance) Check network to re-create if needed...
(vbox-instance) 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 vbox-instance
[root@wknode muten003]# docker-machine env vbox-instance
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/root/.docker/machine/machines/vbox-instance"
export DOCKER_MACHINE_NAME="vbox-instance"
# Run this command to configure your shell: 
# eval $(docker-machine env vbox-instance)

 3.4 远程登录被刚刚创建的虚拟机器

[root@wknode muten003]# docker-machine ssh vbox-instance
   ( '>')
  /) TC (   Core is distributed with ABSOLUTELY NO WARRANTY.
 (/-_--_-)           www.tinycorelinux.net


vim  /etc/ssh/sshd_config将PermitRootLogin yes的注释放开,sudo systemctl restart sshd
[root@wknode cppHelloWorld]# docker-machine create --driver generic --generic-ip-address=192.168.244.142 node-work
Docker machine "node-work" already exists
[root@wknode cppHelloWorld]# 

3.5 切换环境查看被控制机器的情况

[root@wknode muten003]# docker-machine env vbox-instance
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/root/.docker/machine/machines/vbox-instance"
export DOCKER_MACHINE_NAME="vbox-instance"
# Run this command to configure your shell: 
# eval $(docker-machine env vbox-instance)
[root@wknode muten003]# 
[root@wknode muten003]# eval $(docker-machine env vbox-instance)
[root@wknode muten003]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

3.6 将环境切换回docker-machine所在机器

[root@wknode muten003]# docker-machine env -u
unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset DOCKER_MACHINE_NAME
# Run this command to configure your shell: 
# eval $(docker-machine env -u)
[root@wknode muten003]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@wknode muten003]# 
[root@wknode muten003]# eval $(docker-machine env -u)
[root@wknode muten003]# docker images
REPOSITORY                                           TAG       IMAGE ID       CREATED         SIZE
java-image                                           latest    46591cb26793   11 hours ago    584MB
ubuntu                                               14.04     61319561d377   13 hours ago    215MB
test                                                 0.1       5d356f548ba9   14 hours ago    197MB
192.168.244.142:8443/library/redis                   latest    87c26977fd90   12 days ago     113MB
192.168.244.142:8443/library/redis                   v3.0.0    87c26977fd90   12 days ago     113MB
192.168.244.142:8443/library/redis                   v4.0.0    87c26977fd90   12 days ago     113MB
redis                                                latest    87c26977fd90   12 days ago     113MB
ubuntu                                               latest    ff0fea8310f3   12 days ago     72.8MB

4.Machine架构图

最后

以上就是娇气芒果为你收集整理的Docker Machine的全部内容,希望文章能够帮你解决Docker Machine所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部