Windows中Docker启动流程和快速开始

在Windows中使用Docker的方式和在Linux下有所不同,因为Docker不支持在Windows下运行的,Docker的解决方式使用虚拟机来创建Linux环境, 提供真实的类Unix环境给Docker引擎执行,Docker官方默认使用的是开源的VirtualBox,在使用Docker之前请先安装微软虚拟化工具和检查硬件是否支持虚拟化,有以下几点

下载安装

Docker Toolbox

Windows与Linux不同的方式

Linux linux-docker Windows windows-docker

启动流程

下面是Docker在Windows下创建虚拟机和启动Docker引擎的整个流程

Creating CA: C:\Users\Administrator\.docker\machine\certs\ca.pem  

创建根证书

Creating client certificate: C:\Users\Administrator\.docker\machine\certs\cert.em  

创建证书

Running pre-create checks...  

检查系统环境是否是适合使用Docker

Creating machine...  

创建虚拟机

(default) Copying C:\Users\Administrator\.docker\machine\cache\boot2docker.iso

复制boot2docker.iso默认镜像

 C:\Users\Administrator\.docker\machine\machines\default\boot2docker.iso...
(default) Creating VirtualBox VM...

创建VirtualBox

(default) Creating SSH key...

创建SSH Key

(default) Starting the VM...

启动虚拟机

(default) Check network to re-create if needed...

检查网络状态

(default) Windows might ask for the permission to create a network adapter. Somtimes, such confirmation window is minimized in the taskbar.

请求权限创建网络适配器

(default) Found a new host-only adapter: "VirtualBox Host-Only Ethernet Adapter

提示查找到的适配器

(default) Waiting for an IP...

等待DHCP服务分发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...  

配置boot2docker

Copying certs to the local machine directory...  

复制证书到本地主机目录

Copying certs to the remote machine...  
Setting Docker configuration on the remote daemon...  

在远程服务中设置Docker

Checking connection to Docker...  

检查并且连接到Docker

Docker is up and running!  

Docker 已经运行

To see how to connect your Docker Client to the Docker Engine running on this vrtual machine, run:  

查看怎么使用Docker Client客户端连接到运行在虚拟机中Docker

 C:\Program Files\Docker Toolbox\docker-machine.exe env defalt
                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ { / ~   ~=== ~~  ~ ~ <del> </del>~~
           \&#95;&#95;&#95;&#95;&#95;&#95; o           __/
             \    \         __/
              \&#95;&#95;&#95;&#95;\&#95;&#95;&#95;&#95;&#95;&#95;&#95;/
docker is configured to use the default machine with IP 192.168.99.100  
For help getting started, check out the docs at https://docs.docker.com  

docker的默认配置IP地址是192.168.99.100

Start interactive shell  

启动交互shell

$ docker-machine.exe env default
export DOCKER_TLS_VERIFY="1"  
export DOCKER_HOST="tcp://192.168.99.100:2376"  
export DOCKER_CERT_PATH="C:\Users\Administrator\.docker\machine\machines\default"  
export DOCKER_MACHINE_NAME="default"  
# Run this command to configure your shell:
# eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default)

为当前终端设置以上环境变量,这样才能使用docker命令和docker容器进行交互

安装docker容器和启动容器

docker pull index.alauda.cn/kenny/docker-ubuntu  
docker run -i -t  index.alauda.cn\/kenny\/docker-ubuntu /bin/bash  

docker可交互shell

[ root@411e17932c61:/ ]$ ls
bin/   dev/  home/  lib64/  mnt/  proc/  run/   srv/  tmp/  var/  
boot/  etc/  lib/   media/  opt/  root/  sbin/  sys/  usr/  

Doker入门就是这么简单

你的欣赏是我最大的动力

Yanxiong Huang

My name is Yanxiong Huang. graduated from Nanyang middle school.Love Linux,familiar with Node.js,Docker,Serverless... and more Web technology.Contact Me:QQ 31356617;Email:huangaynxiong2013@gmail.com

guangzhou,china http://www.myfreax.com

乐在分享