From: https://blog.csdn.net/jing_zhong/article/details/118083956
Docker在Windows 7下安装
Docker 依赖于已存在并运行的 Linux 内核环境,实质是在已经运行的 Linux 下制造了一个隔离的文件环境,所以如果其他系统想部署 Docker 就必须安装一个虚拟 Linux 环境。而在 Windows 上部署 Docker 的方法都是先安装一个虚拟机,并在安装 Linux 系统的的虚拟机中运行 Docker。
Docker Desktop for Windows作为最简单的安装方式,只能在64位的Windows 10操作系统且带有WSL-2上才能支持安装。
Docker官网对于Win7、Win8操作系统只支持Docker Toolbox方式来安装,若利用 docker toolbox 在Win7系统上安装Docker,国内可以使用阿里云的镜像下载docker-toolbox
2.1 查看Dockers安装的系统硬件要求(与自身系统对比)
进入Install Docker Desktop on Windows页面,可以看到要在Windows系统上安装Docker的系统要求为:WSL 2、Hyper-V、64位处理器、4GB+运行内存、支持虚拟化Virsualization
下图是WIn10系统中可在任务管理器中查看CPU的虚拟化功能是否启用。
2.1.1 电脑系统环境(Win7 64位操作系统+英特尔cpu)
2.1.2 查询电脑是否支持硬件CPU虚拟化
由于Docker需要CPU支持虚拟化功能,首先可以重启电脑进入bios中查看CPU的配置,观察Intel Virtualization Technology 是否为Enabled,如果有要保存为Enabled支持。
使用securable.exe来检测一下SecurAble下载,发现图标都是绿色,说明电脑支持CPU虚拟化,可以在电脑上安装Docker Toolbox。
点击窗口中的三项可以分别查看64-Bit Processing Available、Hardware DEP Available和Hardware Virtualizaiton的具体信介绍。
64-Bit Processing Available
This processor does offer 64-bit modes of operation. This means that this system is able to run the significantly more secure 64-bit versions of Microsoft’s Windows XP and Vista operating systems.
The biggest challenge for 64-bit Windows systems is the fact that existing 32-bit device drivers cannot be used by the 64-bit operating system kernel. So if you do plan to try switching to 64-bit Windows, you should be sure to have a means for reverting to 32-bit operation if your system’s hardware turns out to be incompatible with 64-bit operation. Many people have reverted to 32-bit operation after bravely giving 64-bits a try for a short time.
1
2
3
4
5
Hardware DEP Available
This processor does support hardware-based data execution prevention (DEP).
When hardware DEP support is teamed up with a properly configured operating system (and that part is crucial), computer security mistakes involving the deliberate overrunning of communications buffers can be automatically detected and prevented throughout the entire computer system. This makes data execution prevention, when available and active, the single most promising improvement for PC security ever. Really.
It is very important to note, however, that hardware support for DEP is only one of several enabling requirements that must be met before any benefit can be obtained. GRC will be following up the release of SecurAble with another powerful tool, DEPuty, that will help to properly configure, test and verify the operation of your system’s critical DEP subsystem.
1
2
3
4
5
6
7
Hardware Virtualization
This processor does offer advanced hardware support for virtualization. However, while running under a 64-bit version of Windows this program cannot execute its 32-bit kernel code to determine whether Intel’s VMX virtual machine extensions are being locked on, locked off, or neither. Since there’s a chance that your system’s BIOS may be deliberately disabling support for hardware virtualization (some do) you should re-run this program, if possible, with administrative privileges under a 32-bit version of NT, XP, or Vista. That will allow SecurAble to run a bit of kernel-mode code in order to determine exactly what’s going on. (Note that you can also poke around in your system’s BIOS to see whether you’re able to find any references to “hardware virtualization” or “VMX”, etc.
1
2
3
2.2 下载64位Win7系统下的Docker Toolbox安装包
使用阿里云镜像下载Docker Toolbox,下载完成后如下图所示Docker-Toolbox-1.13.1.exe,大小为200M左右。
2.3 Docker Toolbox安装
Docker Toolbox 是一个工具集,它主要包含以下内容:
Docker CLI – 客户端,用来运行 docker 引擎创建镜像和容器。
Docker Machine – 可以让你在 Windows 的命令行中运行 docker 引擎命令。
Docker Compose – 用来运行 docker-compose 命令。
Kitematic – 这是 Docker 的 GUI 版本。
Docker QuickStart shell- 这是一个已经配置好Docker的命令行环境。
Oracle VM Virtualbox – 虚拟机。
安装步骤比较简单,双击运行DockerToolbox-1.13.1.exe,点击Next
选择安装目录为D:\Docker Toolbox后点击Next
进入选择组件窗口,默认全选即可后一直点击Next进行安装
安装结束后可以在左下角WIndows程序列表中看到Docker目录和Git目录(注:Docker默认会安装Git),
同时桌面上会出现三个图标,如下图所示:
3 启动Docker输入命令测试
3.1 Docker CLI命令学习
通过Docker CLI命令参考文档和Docker 中文手册可以了解Docker命令的一些用法,服务于自己的需求,而常用的测试命令有docker help、docker run和docker version等。
3.2 启动Docker Quickstart Terminal安装ubuntu
为了启动Docker Quickstart Terminal,需要找到Git目录下的bash.exe的路径D:\ServerTool\Git\bin\bash.exe,因为Docker依赖Git的bash,然后在桌面Docker Quickstart Terminal图标上右键选择属性,在属性窗口中找到快捷方式一栏下的目标,在右侧文本框中输入D:\ServerTool\Git\bin\bash.exe –login -i “D:\Docker Toolbox\start.sh”后,现在可以启动Docker Quickstart Terminal,当然也可以在文件目录D:\Docker Toolbox下右键利用Git Bash启动start.sh,这两个的效果是一样的。
在启动Docker Quickstart Terminal或Git启动start.sh的过程中可能会遇到boot2docker.iso下载失败的问题,需要到Github手动下载boot2docker.iso后放到C:\Users\Administrator\.docker\machine\machines\default文件夹下即可,然后再次启动Docker Quickstart Terminal即可成功
输入docker run hello-world后结果如下图所示:
输入docker version后结果如下图所示:
之后输入如下docker命令来安装ubuntu系统,具体命令如下:
docker pull ubuntu //拉取最新版的 Ubuntu 镜像
docker images //查看本地镜像
docker run -itd –name ubuntu-test ubuntu //运行容器ubuntu-test
docker exec -it ubuntu-test /bin/bash //通过 exec 命令进入 ubuntu 容器
ls //linux系统下查看目录命令
1
2
3
4
5
到此位置,ubuntu系统创建完成,可以在b39ad0d37a41下利用root权限执行linux命令了。
3.3 启动Kitematic(Alpha)
打开Kitematic(Alpha)后如下图所示,可以搜索一些Docker Hub上的映像Docker images,并且左下角可以打开Docker CLI命令行窗口,输入docker version可以查看Docker版本信息。
3.4 启动Oracle VM VirtualBox
打开Oracle VM VirtualBox后,新建后的一个默认VM,启动后可看到Docker新建VM的shell窗口,如下图所示:
文章知识点与官方知识档案匹配,可进一步学习相关知识
