Docker“错误:在分配给网络的默认值中找不到可用的,不重叠的IPv4地址池”
我有一个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:latestEXPOSE 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:latestEXPOSE 8118
RUN apk --update add privoxy
COPY config /etc/privoxy/config
CMD ["privoxy", "--no-daemon"]
其中config
由两个线
listen-address 0.0.0.0:8118forward-socks5 / tor:9050 .
而Dockerfile
对于scraper
IS
FROM python:2.7-alpineADD . /scraper
WORKDIR /scraper
RUN pip install -r requirements.txt
CMD ["python", "newnym.py"]
其中requirements.txt
包含单行requests
。最后,该程序newnym.py
旨在简单地测试使用Tor更改IP地址是否有效:
from time import sleep, timeimport 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 driverERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
我尝试搜索有关此错误消息的帮助,但找不到任何帮助。是什么导致此错误?
回答:
遵循彼得·豪格)的评论,在跑步时,docker network ls
我发现(其中包括)以下内容:
NETWORK ID NAME DRIVER SCOPEdc6a83d13f44 bridge bridge local
ea98225c7754 docker_gwbridge bridge local
107dcd8aa889 host host local
NAME
和DRIVER
两者的界线host
似乎就是他所说的“在您的主机上已经创建的网络”。因此,按照https://gist.github.com/bastman/5b57ddb3c11942094f8d0a97d461b430,我运行了命令
docker network rm $(docker network ls | grep "bridge" | awk '/ / { print $1 }')
现在docker-compose up
可以工作(尽管newnym.py
会产生错误)。
以上是 Docker“错误:在分配给网络的默认值中找不到可用的,不重叠的IPv4地址池” 的全部内容, 来源链接: utcz.com/qa/436037.html