先解决docker pull慢的问题:
解决docker pull 速度慢问题
将docker镜像源修改为国内的:
在 /etc/docker/daemon.json 文件中添加以下参数(没有该文件则新建):mac
{
"registry-mirrors": ["https://9cpn8tt6.mirror.aliyuncs.com"]
}
服务重启!
记得是在docker的UI preferrence里设置,然后重启!
然后运行:docker pull kalilinux/kali-rolling
Using default tag: latest
latest: Pulling from kalilinux/kali-rolling
e612541987ab: Pull complete
Digest: sha256:176769d2cbc517b5f482b23c0edc914c2f2025258d8b77b8a561d96b3db598e4
Status: Downloaded newer image for kalilinux/kali-rolling:latest
docker.io/kalilinux/kali-rolling:latest
运行docker images:
REPOSITORY TAG IMAGE ID CREATED SIZE
kalilinux/kali-rolling latest e2377ba97116 11 hours ago 114MB
docker101tutorial latest 9bb5e3121678 4 days ago 27.3MB
<none> <none> 509096ba4128 4 days ago 85.5MB
<none> <none> 2a0ca0c99046 4 days ago 224MB
<none> <none> 30adc0a91c99 4 days ago 72MB
nginx alpine 6f715d38cfe0 4 weeks ago 22.1MB
python alpine 44fceb565b2a 4 weeks ago 42.7MB
node 12-alpine 18f4bc975732 6 weeks ago 89.3MB
可以看到成功安装。然后运行 docker run -t -i kalilinux/kali-rolling /bin/bash
root@a39e83ce3315:/# ls
bin dev home lib32 libx32 mnt proc run srv tmp var
boot etc lib lib64 media opt root sbin sys usr
root@a39e83ce3315:/# pwd然后安装nmap:apt install nmap
错误如下:
解决方法:
终端执行apt update命令,等更新完毕以后再敲命令:apt install nmap命令即可
也可以把kali的工具全部搬过来,使用以下命令安装kali所有的工具,大约十多G
apt install kali-linux-all
我没有这么干,担心mac硬盘不够。
然后发现我要共享mac文件夹给kali,于是:
docker run --name test -it -v /Users/xxx/shell_coders_handbook:/data kalilinux/kali-rolling /bin/bash
root@2e095e14b8b7:/# ls
bin data etc lib lib64 media opt root sbin sys usr
boot dev home lib32 libx32 mnt proc run srv tmp var
root@2e095e14b8b7:/# cd data/
root@2e095e14b8b7:/data# ls
code readme.txt
可以看到已经共享成功了!!!
为了保证你对容器的修改在下次启动进程时依然有效,需要用到commit这个命令。
运行:docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2e095e14b8b7 kalilinux/kali-rolling "/bin/bash" 14 minutes ago Up 14 minutes test
然后提交下镜像:docker commit 2e095e14b8b7 docker-kali-shared
sha256:9dd1ffeca50469ddeb4332be535b3827840c3b893f76c17afbedf89afa63c808
看下是否成功: docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-kali-shared latest 9dd1ffeca504 About a minute ago 353MB
下次运行的时候:
docker run --name test -it -v /Users/xxx/shell_coders_handbook:/data docker-kali-shared /bin/bash
就可以看到上次对容器的修改依然在内,包括你安装的软件神马的都是在的,就不用重复折腾了!
补充:
docker commit :从容器创建一个新的镜像。
语法
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
OPTIONS说明:
- -a :提交的镜像作者;
- -c :使用Dockerfile指令来创建镜像;
- -m :提交时的说明文字;
- -p :在commit时,将容器暂停。
实例
将容器a404c6c174a2 保存为新的镜像,并添加提交人信息和说明信息。
runoob@runoob:~$ docker commit -a "runoob.com" -m "my apache" a404c6c174a2 mymysql:v1
sha256:37af1236adef1544e8886be23010b66577647a40bc02c0885a6600b33ee28057
runoob@runoob:~$ docker images mymysql:v1
REPOSITORY TAG IMAGE ID CREATED SIZE
mymysql v1 37af1236adef 15 seconds ago 329 MB
标签:ago,kali,mac,kalilinux,rolling,docker,root From: https://blog.51cto.com/u_11908275/6393178