Docker 在win10 home系统上安装笔记
一,Windows10家庭版添加Hyper-V虚拟机的方法
1.复制下面脚本到记事本中,并命名为Hyper-V.cmd,找到文件并右键点击,在右键菜单中点击以管理员身份运行,等待处理完毕,输入Y,电脑开始重启,注意不能关机
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
控制面板–>程序–>程序和功能–>点击启用或关闭Windows功能,看到Hyper-V的存在,此时已经打√,点击确认
二,Install Windows Subsystem for Linux (WSL) on Windows 10
参考官方的步骤:Install Windows Subsystem for Linux (WSL) on Windows 10,选择Manual install方案,一共6步。
1.Enable the Windows Subsystem for Linux**
Open PowerShell:在任务栏中的Cortana搜索框中输入PowerShell,即可搜索到Windows PowerShell桌面应用,点击即可打开,右键以管理员身份打开
输入命令,后回车
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
此处我安装WSL2,故需第二步骤,对WSL进行更新
2.Check requirements for running WSL 2
- For x64 systems: Version 1903 or higher, with Build 18362 or higher.
Windows 键+ R,输入winver, 检查自己的版本,我这里的版本是1909,内部版本号是18363.1379,要求必须大于18362.1049 或者18363.1049,否则需要对电脑进行检查更新
3.Enable Virtual Machine feature
在安装WSL2之前,在PowerShell中输入以下命令
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
然后重启电脑
4.Download the Linux kernel update package
我的版本是x64,下载包:WSL2 Linux kernel update package for x64 machines。
其他详情看:https://docs.microsoft.com/en-us/windows/wsl/install-win10中第四步骤,包的链接在其中也有。
双击下载的包,运行,安装成功
5.Set WSL 2 as your default version
打开PowerShell并运行以下命令,以便在安装新的Linux时将WSL 2设置为默认版本:
6.Install your Linux distribution of choice
在Microsoft Store中安装Ubuntu 16.04.LTS
安装成功后,需要重启电脑,才能打开Ubuntu 16.04 LTS
安装Docker Desktop for Windows
在官网下载Docker Desktop for Windows。
地址为:https://hub.docker.com/editions/community/docker-ce-desktop-windows/
下载成功后,双击文件,点击ok
打开Docker,注册自己的账号并登陆
三,在天池创建镜像仓库
阿里云容器服务地址为:https://cr.console.aliyun.com
注册开通后的界面:
1. 创建命名空间
第一步切换标签页到命名空间,创建地址唯一的命名空间
2. 创建镜像仓库
根据大赛要求选择对应的地域,其他的按照自己需求选择或填写
选择代码源为本地仓库,灵活度大,完成创建
点击管理,可查看详情。
3,根据管理中的操作指南,进行本地登录
注意我这里win系统,故输入命令不要sudo
输入登录命令:
docker login --username=自己账号名 registry.cn-shenzhen.aliyuncs.com
登录成功
4.安装好Docker环境的本机/服务器构建并推送容器镜像。
过程中可能会使用docker命令,如拉取docker pull,推送docker push,构建docker build等等。
为简化构建镜像的难度,天池已准备了常用的Python基础镜像,可直接拉取使用,自行构建镜像请确保安装curl.更多基础镜像说明可参考:https://tianchi.aliyun.com/forum/postDetail?postId=67720。
docker pull registry.cn-shanghai.aliyuncs.com/tcc-public/python:3
** 整理好baseline**
打开PowerShell进入baseline_docker目录,直接进行命令行操作
登陆
输入
docker build -t registry.cn-shenzhen.aliyuncs.com/ai_contest/ai_contest_submit:1.0 .
由于网络问题,超时报错
加下pip --timeout=600 install -i https://pypi前面这个timeout参数
再次输入
docker build -t registry.cn-shenzhen.aliyuncs.com/ai_contest/ai_contest_submit:1.0 .
** 成功后,push,输入以下命令。需要等待好一会儿**
docker push registry.cn-shenzhen.aliyuncs.com/ai_contest/ai_contest_submit:1.0
push成功后在在左侧【提交结果】中点击配置路径填写推送的镜像路径、用户名和密码,即可提交。
根据【我的成绩】中的分数和日志可以查看运行情况。