1. 在centos7上安装docker
#安装docker
yum install docker -y
#安装docker阿里云加速器,下面的PRIVATE_ID请换成自己的docker的仓库id
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://PRIVATE_ID.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
#启动docker
systemctl start docker
#设置系统启动加载docker服务
chkconfig docker on
2. 下载最新centos镜像并运行容器
#下载centos:latest
docker pull docker.io/centos:latest
#查看image id = 84c2xxxx
docker images
#创建共享目录
mkdir -p /root/docker/shared
#运行容器,预留ssh 22端口映射为10022;预留mariaDB 3306映射为13306
docker run -p 10022:22 -p 13306:3306 --privileged --name centos -v /root/docker/shared:/mnt/shared -it docker.io/centos:latest /sbin/init
3. 在镜像中安装scrapy爬虫环境
#安装必要工具
yum install vim openssl-devel bzip2-devel expat-devel gdbm-devel