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

2023年 7月 20日 126.2k 0

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

  • CPU必须支持虚拟化技术Intel VT-x or AMD-V
  • Windows7 用户请安装 Microsoft® Hardware-Assisted Virtualization Detection Tool

下载安装

Docker Toolbox

Windows与Linux不同的方式

Linux
linux-docker
Windows
windows-docker

启动流程

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

Creating CA: C:UsersAdministrator.dockermachinecertsca.pem

创建根证书

Creating client certificate: C:UsersAdministrator.dockermachinecertscert.em

创建证书

Running pre-create checks...

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

Creating machine...

创建虚拟机

(default) Copying C:UsersAdministrator.dockermachinecacheboot2docker.iso

复制boot2docker.iso默认镜像

 C:UsersAdministrator.dockermachinemachinesdefaultboot2docker.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 FilesDocker Toolboxdocker-machine.exe env defalt

                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""___/ ===
      ~~~ { / ~   ~=== ~~  ~ ~ ~~ ~~~~
           ______ o           __/
                          __/
              ___________/
```
```shell
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
```shell
Start interactive shell
```
启动交互shell
```shell
$ docker-machine.exe env default
```

```bash
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="C:UsersAdministrator.dockermachinemachinesdefault"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval $("C:Program FilesDocker Toolboxdocker-machine.exe" env default)
```
为当前终端设置以上环境变量,这样才能使用docker命令和docker容器进行交互
##安装docker容器和启动容器
```shell
docker pull index.alauda.cn/kenny/docker-ubuntu
docker run -i -t  index.alauda.cn/kenny/docker-ubuntu /bin/bash
```
##docker可交互shell
```shell
[ root@411e17932c61:/ ]$ ls
bin/   dev/  home/  lib64/  mnt/  proc/  run/   srv/  tmp/  var/
boot/  etc/  lib/   media/  opt/  root/  sbin/  sys/  usr/
```
>Doker入门就是这么简单

相关文章

LeaferJS 1.0 重磅发布:强悍的前端 Canvas 渲染引擎
10分钟搞定支持通配符的永久有效免费HTTPS证书
300 多个 Microsoft Excel 快捷方式
一步步配置基于kubeadmin的kubevip高可用
istio全链路传递cookie和header灰度
REST Web 服务版本控制

发布评论