目录
5.docker info有一个小警告:WARNING: No swap limit support
出现错误:Error response from daemon: No such container:
1.什么是docker?
https://www.cnblogs.com/qdhxhz/p/9853265.html
2.docker中三个概念:仓库、镜像、容器的理解。
https://www.cnblogs.com/qdhxhz/p/9865658.html
3.安装
ubantu https://www.cnblogs.com/qdhxhz/p/9879588.html
自己是kali的,主要看这个:https://blog.csdn.net/u013814153/article/details/53925790
解决 无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用):
https://blog.csdn.net/xiaosshhaa/article/details/75674750
sudo apt-get update由于没有公钥,无法验证下列签名:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6DA746A05F00FA99(签名)
apt-get update
apt-get install docker-engine
# 安装结束,打开docker服务
service docker start
# 验证安装,运行测试样例
docker run hello-world
# 如果没有错误就大功造成了!
4.kali命令集:
https://www.cnblogs.com/webyihui/p/3996023.html
重启:reboot
5.docker info有一个小警告:WARNING: No swap limit support
解决办法:
When users run Docker, they may see these messages when working with an image: WARNING: Your kernel does not support cgroup swap limit. WARNING: Your kernel does not support swap limit capabilities. Limitation discarded. To prevent these messages, enable memory and swap accounting on your system. To enable these on system using GNU GRUB (GNU GRand Unified Bootloader), do the following. Log into Ubuntu as a user with sudo privileges. Edit the /etc/default/grub file. Set the GRUB_CMDLINE_LINUX value as follows: GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1" Save and close the file. Update GRUB. $ sudo update-grub Reboot your system.
sudo gedit /etc/default/grub
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
sudo update-grub
reboot
告警消失:
6.docker命令集
①镜像命令
搜索镜像
docker search 镜像名称
列出当前系统存在的镜像
docker images
拉取镜像
docker pull image_name
docker pull image_name:tag
#image_name:表示镜像的仓库源名称,TAG:镜像的标签 如果不指定tag 那么默认用最新的
删除镜像
docker rmi 镜像名称/镜像ID
docker rmi -f 镜像名称/镜像ID
#强制删除 如果镜像有容器在运行 那么就需要强制删除 增加 -f 参数
举例
docker search nginx #搜索所有nginx相关的镜像列表(模糊查询)
docker pull nginx #拉取nginx镜像
docker pull nginx:stable #拉取tag为stable的nginx
②容器命令
运行容器
docker run #首先会从本地找镜像,如果有则直接启动,没有的话,从镜像仓库拉起,再启动)
docker run -d --name "xiaoxiao" -p 5672:5672 -p 15672:15672 rabbitmq:management
#-d 后台运行
#-p 端口映射 (可以有多个 因为该镜像可能存在多个端口)
#rabbitmq:management (格式 REPOSITORY:TAG),如果不指定tag,默认使用最新的
#--name 给该容器取个名字
列举当前运行的容器
docker ps
检查容器内部信息
docker inspect 容器名称
停止某个容器
docker stop 容器名称
启动某个容器
docker start 容器名称
移除某个容器
docker rm 容器名称 (容器必须是停止状态)
7.查看启动镜像
docker run -d --name "sqli" -p80:80 --rm acgpiano/sqli-labs
--rm
是删除所有相关产生的镜像,防止不停创建镜像占用过多的资源。
尝试其他命令:
出现错误:Error response from daemon: No such container:
解决办法:
docker run 与docker exec的区别:
https://blog.csdn.net/qq_36320549/article/details/89916744
1.sudo docker run -t -i 容器名字 /bin/bash
在docker命令后面指定命令参数,执行完毕后进入了镜像:
acgpiano/sqli-labs
sudo docker run -t -i acgpiano/sqli-labs /bin/bash
2.docker exec -it 容器名字 /bin/bash
8.安装Mysql
忘记mysql密码了?
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
刚刚捣鼓了一圈,o(╥﹏╥)o,以为数据库是在kali上的,这个数据库应该是sqli-labs自带的!o(╥﹏╥)o,
也不知道为啥 我捣鼓来一圈回来就好了,难道是我换了个启动这个环境的命令?
docker exec -it c779a6afce82 /bin/bash
好了,总算安装完成了。不知道我那捣鼓一圈的在kali上的Mysql会不会对以后的环境有啥影响,不过我创建了以前的快照,应该也不慌。