使用docker-machine 创建virtualbox虚拟机时指定boot2docker.iso位置和设置docker镜像加速的命令

Posted top66zhoulei

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用docker-machine 创建virtualbox虚拟机时指定boot2docker.iso位置和设置docker镜像加速的命令相关的知识,希望对你有一定的参考价值。

使用docker-machine 创建virtualbox虚拟机时指定boot2docker.iso位置和设置docker镜像加速的命令

docker-machine create -d virtualbox --virtualbox-boot2docker-url=/home/当前用户/.docker/machine/cache/boot2docker2.iso --engine-registry-mirror=https://3qtk5f5j.mirror.aliyuncs.com node1

-d virtualbox为指定virtualbox创建虚拟机

-virtualbox-boot2docker-url=/home/当前用户/.docker/machine/cache/boot2docker2.iso 指定 boot2docker.iso 文件并且可以跳过国内网络不识别github最新版boot2docker.iso文件的问题

--engine-registry-mirror=https://3qtk5f5j.mirror.aliyuncs.com 可以直接在创建虚拟机的时候就将加速地址写入,容器镜像下载嗖嗖嗖嗖~

 1 zhoulei@zhoulei-PC:~/Desktop$ docker-machine create -d virtualbox --virtualbox-boot2docker-url=/home/zhoulei/.docker/machine/cache/boot2docker.iso --engine-registry-mirror=https://3qtk5f5j.mirror.aliyuncs.com node2
 2 Running pre-create checks...
 3 (node2) Boot2Docker URL was explicitly set to "/home/zhoulei/.docker/machine/cache/boot2docker.iso" at create time, so Docker Machine cannot upgrade this machine to the latest version.
 4 Creating machine...
 5 (node2) Boot2Docker URL was explicitly set to "/home/zhoulei/.docker/machine/cache/boot2docker.iso" at create time, so Docker Machine cannot upgrade this machine to the latest version.
 6 (node2) Downloading /home/zhoulei/.docker/machine/cache/boot2docker.iso from /home/zhoulei/.docker/machine/cache/boot2docker.iso...
 7 (node2) Creating VirtualBox VM...
 8 (node2) Creating SSH key...
 9 (node2) Starting the VM...
10 (node2) Check network to re-create if needed...
11 (node2) Waiting for an IP...
12 Waiting for machine to be running, this may take a few minutes...
13 Detecting operating system of created instance...
14 Waiting for SSH to be available...
15 Detecting the provisioner...
16 Provisioning with boot2docker...
17 Copying certs to the local machine directory...
18 Copying certs to the remote machine...
19 Setting Docker configuration on the remote daemon...
20 Checking connection to Docker...
21 Docker is up and running!
22 To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env node2

 

 

 
 1 zhoulei@zhoulei-PC:~/Desktop$ docker-machine ssh node2 "docker pull ubuntu"
 2 Using default tag: latest
 3 latest: Pulling from library/ubuntu
 4 5667fdb72017: Pulling fs layer
 5 d83811f270d5: Pulling fs layer
 6 ee671aafb583: Pulling fs layer
 7 7fc152dfb3a6: Pulling fs layer
 8 7fc152dfb3a6: Waiting
 9 ee671aafb583: Verifying Checksum
10 ee671aafb583: Download complete
11 d83811f270d5: Verifying Checksum
12 d83811f270d5: Download complete
13 7fc152dfb3a6: Verifying Checksum
14 7fc152dfb3a6: Download complete
15 5667fdb72017: Verifying Checksum
16 5667fdb72017: Download complete
17 5667fdb72017: Pull complete
18 d83811f270d5: Pull complete
19 ee671aafb583: Pull complete
20 7fc152dfb3a6: Pull complete
21 Digest: sha256:b88f8848e9a1a4e4558ba7cfc4acc5879e1d0e7ac06401409062ad2627e6fb58
22 Status: Downloaded newer image for ubuntu:latest
23 docker.io/library/ubuntu:latest
24 zhoulei@zhoulei-PC:~/Desktop$ docker-machine ssh node2 "docker image ls"
25 REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
26 ubuntu              latest              2ca708c1c9cc        3 weeks ago         64.2MB
27 zhoulei@zhoulei-PC:~/Desktop$ 

可以看到镜像已经下载下来了

以上是关于使用docker-machine 创建virtualbox虚拟机时指定boot2docker.iso位置和设置docker镜像加速的命令的主要内容,如果未能解决你的问题,请参考以下文章

docker-machine 创建主机的缺省密码 (Default User and Password)

在不同 docker-compose 文件中描述并在不同 docker-machines 中运行的容器之间创建 NFS 共享

容器技术|Docker三剑客之docker-machine

使用 'localhost' 连接到 docker-machine

随手记录docker-machine create ... IP not found for MAC xxx in DHCP leases

docker-machine 快速搭建docker环境