docker安装p2pspider-荒岛

  • A+
摘要

闲来无事把这个p2pspider给容器化了,有想图方便的可以试一试。安装docker和docker-compose:

闲来无事把这个p2pspider给容器化了,有想图方便的可以试一试。

安装docker和docker-compose:

apt -y update  apt -y install curl  curl -sSL https://get.docker.com/ | sh  systemctl start docker  systemctl enable docker  curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose  chmod +x /usr/local/bin/docker-compose

新建一个目录/新建一个docker-compose.yml文件:

mkdir -p /opt/p2pspider-docker && cd /opt/p2pspider-docker && nano docker-compose.yml

 

mkdir -p /opt/p2pspider-docker && cd /opt/p2pspider-docker && nano docker-compose.yml

写入如下配置:

version: '3.5'    services:      spider:          image: imlala/p2pspider:latest          container_name: p2pspider          depends_on:              - mongodb-spider              - redis-spider          environment:              - SITE_NAME=TorrentDatabase              - USER_NAME=imlala              - PASS_WORD=23333              - SPIDER_MODE=1              - MONGODB_HOST=mongodb://mongodb-spider              - REDIS_HOST=redis-spider          ports:              - "8080:8080"              - "6881:6881/udp"          restart: unless-stopped        mongodb-spider:          image: mongo          container_name: mongodb-spider          volumes:              - ./mongodb:/data/db          restart: unless-stopped        redis-spider:          image: redis          container_name: redis-spider          restart: unless-stopped

几个environment的使用方法:

1.SITE_NAME设置你的网站名字,可以任意填写。

2.USER_NAME/PASS_WORD设置你的账号和密码,如果你想公开给任何人访问这两个env可以不设置直接删除即可。

3.SPIDER_MODE可选配置1/2/3,1代表1H1G的配置,2代表2H2G的配置,3代表最大效率运行爬虫。不设置这个env表示最小配置(512M内存)

4.MONGODB_HOST/REDIS_HOST的主机名必须和docker-compose下面的服务名对应。

没问题up起来即可:

docker-compose up -d

配置反代+域名+SSL访问可以用Traefik这里就不多说了,没安装Traefik可以按照这篇文章安装一下:

Docker+Traefik快速安装PlayTube

贴一个Traefik的配置:

version: '3.5'    services:      spider:          image: imlala/p2pspider:latest          container_name: p2pspider          depends_on:              - mongodb-spider              - redis-spider          environment:              - SITE_NAME=TorrentDatabase              - USER_NAME=imlala              - PASS_WORD=23333              - SPIDER_MODE=1              - MONGODB_HOST=mongodb://mongodb-spider              - REDIS_HOST=redis-spider          ports:              - "6881:6881/udp"          labels:               - "traefik.port=8080"              - "traefik.frontend.rule=Host:dht.233.fi"          restart: unless-stopped        mongodb-spider:          image: mongo          container_name: mongodb-spider          volumes:              - ./mongodb:/data/db          labels:               - "traefik.enable=false"          restart: unless-stopped        redis-spider:          image: redis          container_name: redis-spider          labels:               - "traefik.enable=false"          restart: unless-stopped    networks:      default:          external:              name: imlala

备份还原很简单,直接打包/opt/p2pspider-docker目录,传到别的机器上解压up起来即可。

docker安装p2pspider-荒岛

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: