一、下载docker
二、安装
- 2.1 双击下载 程序
- 2.2 next
- 2.3 next
- 2.4 next
- 2.5 install
三、打开vbox
四、直接运行 Docker Quickstart Terminal
- 4.1 这个过程会下载 boot2docker.iso, 并在vbox 上新建default虚拟机的
这个过程可能很漫长, 也可能安装不成功。
如果vbox中没有一直没有default的虚拟名,那么可以用下面的方法
- 4.2 上面如果成功了,请忽略此处,直接跳到 五(下面时创建了一个node1的虚拟机)
- 4.2.1 docker-machine create --driver virtualbox node1
Running pre-create checks...
(node1) No default Boot2Docker ISO found locally, downloading the latest release...
(node1) Latest release for github.com/boot2docker/boot2docker is v19.03.5
(node1) Downloading C:UsersMaibenben.dockermachinecacheoot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v19.03.5/boot2docker.iso...
(node1) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(node1) Copying C:UsersMaibenben.dockermachinecacheoot2docker.iso to C:UsersMaibenben.dockermachinemachines
ode1oot2docker.iso...
(node1) Creating VirtualBox VM...
(node1) Creating SSH key...
(node1) Starting the VM...
(node1) Check network to re-create if needed...
(node1) Windows might ask for the permission to create a network adapter. Sometimes, such confirmation window is minimized in the taskbar.
(node1) Found a new host-only adapter: "VirtualBox Host-Only Ethernet Adapter #2"
(node1) Windows might ask for the permission to configure a network adapter. Sometimes, such confirmation window is minimized in the taskbar.
(node1) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(node1) 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 node1
* 4.2.2 docker version
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24302
Built: Fri Mar 23 08:31:36 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.37/version: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
* 4.2.3 上面有报错 请运行
> docker-machine env node1
// docker-machine env 需要指定使用哪个虚拟镜像, 默认时default
SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.168.99.100:2376
SET DOCKER_CERT_PATH=C:UsersMaibenben.dockermachinemachines
ode1
SET DOCKER_MACHINE_NAME=node1
SET COMPOSE_CONVERT_WINDOWS_PATHS=true
REM Run this command to configure your shell:
REM @FOR /f "tokens=*" %i IN ('docker-machine env node1') DO @%i
* 4.2.4 根据 上面的提示,逐一运行(根据自己运行 docker-machine env node1,返回的结果运行)
C:UsersMaibenben>SET DOCKER_TLS_VERIFY=1
C:UsersMaibenben>SET DOCKER_HOST=tcp://192.168.99.100:2376
C:UsersMaibenben>SET DOCKER_CERT_PATH=C:UsersMaibenben.dockermachinemachines
ode1
C:UsersMaibenben>SET DOCKER_MACHINE_NAME=node1
C:UsersMaibenben>SET COMPOSE_CONVERT_WINDOWS_PATHS=true
C:UsersMaibenben>REM Run this command to configure your shell:
C:UsersMaibenben>REM @FOR /f "tokens=*" %i IN ('docker-machine env node1') DO @%i
* 4.2.5 docker version
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24302
Built: Fri Mar 23 08:31:36 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea838
Built: Wed Nov 13 07:28:45 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683
五、安装完成 可以运行了
docker search nginx
此时可以看到搜索到NGINX镜像
六、 docker VM bash
- 6.1 如何进入docker VM bash
docker-machine ssh // 默认进入名为default的虚拟镜像 进入node1 :docke-machine ssh node1
- 6.2 修改 docker 下载源
sudo vi /var/lib/boot2docker/profile
在EXTRA_ARGS= 中加入下面一句
--registry-mirror=https://registry.docker-cn.com
EXTRA_ARGS='
--label provider=virtualbox
--registry-mirror=https://registry.docker-cn.com
'
CACERT=/var/lib/boot2docker/ca.pem
DOCKER_HOST='-H tcp://0.0.0.0:2376'
DOCKER_STORAGE=aufs
DOCKER_TLS=auto
SERVERKEY=/var/lib/boot2docker/server-key.pem
SERVERCERT=/var/lib/boot2docker/server.pem
docker-machine restart
// 重启docker-machine 默认重启的时default; 重启node1 的虚拟镜像 : docker-machine restart node1
- 6.3 查看虚拟机的ip 地址
docker-machine ip node1
// 这是查看的时docekr vm 的ip 地址
如何开了docker 容器的端口映射的话通过 这个Ip:prot 进行访问即可
- 6.4 关闭docker Vm
docker-machine stop node1 // 默认关闭default: docker-machine stop
- 6.5 关于docekr-machine 的其他用法
docekr-machine -help
- 6.6 启动docker vm
先打开 vbox
docker-machine start node1
// 默认启动的default
// 启动之后还是需要执行 docker-machine env node1 ,在执行里面的命令
七 解释
docker-machine ls
// 查看 docker 在vbox 中可以可用的虚拟镜像(docker VM bash)
docker-machine create --driver virtualbox node1
// 在vbox 中 创建一个名为 node1 的虚拟镜像