apkmirror-scraper-compose
निम्नलिखित संरचना के साथ मेरे पास एक निर्देशिका है :
.
├── docker-compose.yml
├── privoxy
│ ├── config
│ └── Dockerfile
├── scraper
│ ├── Dockerfile
│ ├── newnym.py
│ └── requirements.txt
└── tor
└── Dockerfile
मैं निम्नलिखित को चलाने की कोशिश कर रहा हूं docker-compose.yml
:
version: '3'
services:
privoxy:
build: ./privoxy
ports:
- "8118:8118"
links:
- tor
tor:
build:
context: ./tor
args:
password: ""
ports:
- "9050:9050"
- "9051:9051"
scraper:
build: ./scraper
links:
- tor
- privoxy
जहां के Dockerfile
लिए tor
है
FROM alpine:latest
EXPOSE 9050 9051
ARG password
RUN apk --update add tor
RUN echo "ControlPort 9051" >> /etc/tor/torrc
RUN echo "HashedControlPassword $(tor --quiet --hash-password $password)" >> /etc/tor/torrc
CMD ["tor"]
उसके लिए privoxy
है
FROM alpine:latest
EXPOSE 8118
RUN apk --update add privoxy
COPY config /etc/privoxy/config
CMD ["privoxy", "--no-daemon"]
जहां config
दो पंक्तियों के होते हैं
listen-address 0.0.0.0:8118
forward-socks5 / tor:9050 .
और के Dockerfile
लिए scraper
है
FROM python:2.7-alpine
ADD . /scraper
WORKDIR /scraper
RUN pip install -r requirements.txt
CMD ["python", "newnym.py"]
जहाँ requirements.txt
एकल पंक्ति है requests
। अंत में, प्रोग्राम newnym.py
को बस यह जांचने के लिए डिज़ाइन किया गया है कि क्या टोर का उपयोग करके आईपी एड्रेस को बदलना काम कर रहा है:
from time import sleep, time
import requests as req
import telnetlib
def get_ip():
IPECHO_ENDPOINT = 'http://ipecho.net/plain'
HTTP_PROXY = 'http://privoxy:8118'
return req.get(IPECHO_ENDPOINT, proxies={'http': HTTP_PROXY}).text
def request_ip_change():
tn = telnetlib.Telnet('tor', 9051)
tn.read_until("Escape character is '^]'.", 2)
tn.write('AUTHENTICATE ""\r\n')
tn.read_until("250 OK", 2)
tn.write("signal NEWNYM\r\n")
tn.read_until("250 OK", 2)
tn.write("quit\r\n")
tn.close()
if __name__ == '__main__':
dts = []
try:
while True:
ip = get_ip()
t0 = time()
request_ip_change()
while True:
new_ip = get_ip()
if new_ip == ip:
sleep(1)
else:
break
dt = time() - t0
dts.append(dt)
print("{} -> {} in ~{}s".format(ip, new_ip, int(dt)))
except KeyboardInterrupt:
print("Stopping...")
print("Average: {}".format(sum(dts) / len(dts)))
docker-compose build
सफलतापूर्वक बनाता है, लेकिन अगर मैं कोशिश docker-compose up
, मैं निम्न त्रुटि संदेश मिलता है:
Creating network "apkmirrorscrapercompose_default" with the default driver
ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
मैंने इस त्रुटि संदेश पर मदद की तलाश की, लेकिन कोई भी नहीं खोज सका। इस त्रुटि के कारण क्या है?
docker network ls
और पुष्टि कर सकते हैं कि नेटवर्क पहले से ही आपके होस्ट पर बनाए गए थे।
docker network prune
। इससे आपकी समस्या का समाधान हो जाएगा
docker ps
कोई कंटेनर नहीं दिखा रहा है।