win10下的docker下的kali安装备忘录

考试结束后的第二天,当我开开心心的打开我的bash版kali……
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80070057
Error: 0x80070057 ?????
Press any key to continue...

  • 尝试更新windows,修复更新错误,没有用(有用才会很奇怪的吧)
  • 尝试修复应用,无果。
  • 心一横重置应用,好了……
    bash虽然好,一旦崩了就是真的崩啊……我脆弱的心灵承受不起这样的打击了!一边这样说着一边点开全新的kali准备从头再来,发现上次没有记笔记……


绝望了这次是真的绝望了!没关系不记得就算了!我们另起炉灶干脆来装docker然后跑kali!这总不怕崩了! (崩了也是另一种新的痛苦,反正圣斗士不能在同一个地方倒下两次)

  1. windows功能选项中打开“容器”,确定,重启。

  2. 下载docker for windows并安装
    https://docs.docker.com/docker-for-windows/install/

  3. pull官方的kali镜像,因为懒,准备直接把run命令执行两次完事,但是无奈何速度太慢,搜了下指定国内官方镜像加速,果然快了好多倍……
    > docker pull registry.docker-cn.com/kalilinux/kali-linux-docker
    > docker run -t -i kalilinux/kali-linux-docker /bin/bash --cap-add list

    加速点是真的快惹!

  4. 根据大佬的建议,让我们先精简下更新下包。(感觉并没有什么用)
    > apt update && apt full-upgrade && apt auto-remove&& apt-autoclean

  5. 开始安装各种包和更新源
    > apt-get install vim #首先安装完后想更新source,发现vim没装……
    > vim /etc/apt/sources.list
    deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
    deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
    ……emmm那我前面更新个什么劲
    6.保存对容器的修改
    > docker ps #新起一个窗口,查看docker进程

    id:fa838ec66bb6

    > docker commit -p fa838ec66bb6 kali-backup #创建快照,可用docker images查看当前镜像
    > docker save -o d:\\security\docker\kali-backup00.tar kali-backup #创建镜像备份
    > docker load -i d:\\security\docker\kali-backup00.tar #加载镜像备份
    > docker run --name ctf -t kali-backup #通过镜像运行container
    > docker attach name/cid #进入正在运行的容器
    > docker run -it -v c:\\Users\ben\Desktop:/home/ kali-backup #挂载本地目录

  6. 根据Dockfile生成镜像(漫长的被坑过程)

  • 来到Dockfile所在文件夹准备build,失败。注意最后要加空格后加英文句号
> PS D:\security\docker\mining_server> docker build -t mining.
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage:  docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
> PS D:\security\docker\mining_server> docker build -t mining . #生成叫mining的镜像
Sending build context to Docker daemon  40.47MB
Step 1/34 : FROM phusion/baseimage
Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
  • 然后pull不下来,更新registry-mirros后搞定。
    更新方式:找到C:\Program Files\Docker\Docker\resources\linux-daemon-options.json,将"registry-mirrors": ["registry|redacted"],改成"https://docker.mirrors.ustc.edu.cn",然后右键重启dockers(我是win10我骄傲,我为祖国省键盘)
> PS D:\security\docker\mining_server> docker pull phusion/baseimage
Using default tag: latest
Error response from daemon: Get https://registry.docker-cn.com/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
> PS D:\security\docker\mining_server> docker pull phusion/baseimage
Using default tag: latest
latest: Pulling from phusion/baseimage
281a73dee007: Downloading [==============>                                    ]  719.5kB/2.559MB
2aea1b77cff7: Download complete
59a714b7d8bf: Download complete
0218064da0a9: Download complete
ebac621dcea3: Download complete
a3ed95caeb02: Download complete
b580731643cc: Download complete
faa5fbdba239: Download complete

总结

  1. 因为有了镜像功能,内心的石头终于落地了!但是每次都要commit再run吗好麻烦!明天再研究下是不是真的!(是真的)
  2. 明天的作业是搞定docker挂载本地目录……不然和bash真是没法比,要不还是把bash版各插件装好把(喂)
    加入了挂载本地的
    docker run -it --name ctf -v d:\ctf-task:/tmp kali-backup
    中间出现了错误提示
    PS C:\WINDOWS\system32> docker run -it -v d:\security\docker:/tmp kali-backup C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: Drive has not been shared.
    搜了下(问了下大佬),是因为windows下需要右键修改配置……
    修改shared drivers

你可能感兴趣的:(win10下的docker下的kali安装备忘录)