contos7下使用docker安装vulhub
1. 安装docker
1. 更新yum
(1)切换root用户
su root
(2)更新yum
yum update
2. 卸载旧版本的docker
sudo yum remove docker
sudo yum remove docker-client
sudo yum remove docker-client-latest
sudo yum remove docker-common
sudo yum remove docker-latest
sudo yum remove docker-latest-logrotate
sudo yum remove docker-logrotate
sudo yum remove docker-engine
3. 安装docker
安装工具:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
设置阿里镜像
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新yum缓存
sudo yum makecache fast
查看可用yum列表
yum list docker-ce --showduplicates | sort -r
安装固定版本docker
yum install docker-ce-17.06.2.ce-1.el7.centos
查看docker版本
docker version
4. 启动服务
systemctl start docker
systemctl enable docker #开机自启
2. 使用docker
2.1 换源
vim /etc/docker/daemon.json
{"registry-mirrors":["https://9cpn8tt6.mirror.aliyuncs.com","https://registry.docker-cn.com"]
}
sudo systemctl daemon-reload
sudo systemctl restart docker.service
2.2 使用docker搭建vulhub服务
2.2.1 安装docker-compose
2.2.1.1安装gcc等编译环境
yum install zlib zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
2.2.1.2安装python3
- 下载
wget https://www.python.org/ftp/python/3.9.18/Python-3.9.18.tgz
- 解压
tar -zxvf Python-3.9.18.tgz
- 执行编译文件,安装
cd Python-3.9.18/
./configure --prefix=/usr/local/python3
make && make install
- 配置环境变量(建立软连接)
ln -s /usr/local/python3/bin/python3.9 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.9 /usr/bin/pip3
2.2.1.3安装docker-compose
pip3 install docker-compose==1.24.0
docker-compose建立软连接
ln -s /usr/local/python3/bin/docker-compose /usr/bin/docker-compose
查看是否安装完成
docker-compose --version
如果报错
pip3 install urllib3==1.26.15
2.2.2 安装vulhub
去git上下载:GitHub - vulhub/vulhub: Pre-Built Vulnerable Environments Based on Docker-Compose
wget https://github.com/vulhub/vulhub/archive/master.zip -O vulhub-master.zip
unzip vulhub-master.zip
启动docker
systemctl start docker
d29e7c38e51d222ddf1b65a7e4136329e9c103eb30a073549b6c7be967133c41
cd /etc/selinux/
cat config
SELINUX=disabled
2.2.3 启动某个漏洞
docker-compose up -d
3549b6c7be967133c41
cd /etc/selinux/
cat config
[外链图片转存中…(img-pr0MSEUX-1717859470572)]
SELINUX=disabled
2.2.3 启动某个漏洞
docker-compose up -d