gpt4 book ai didi

python - docker "ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network"

转载 作者:IT老高 更新时间:2023-10-28 12:33:47 29 4
gpt4 key购买 nike

我有一个目录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

torDockerfile 在哪里

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 .

scraperDockerfile

FROM python:2.7-alpine
ADD . /scraper
WORKDIR /scraper
RUN pip install -r requirements.txt
CMD ["python", "newnym.py"]

其中 requirements.txt 包含单行 requests。最后,程序 newnym.py 旨在简单地测试使用 Tor 更改 IP 地址是否有效:

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 可能处于创建网络的最大值。命令 docker network prune 可用于删除至少一个容器未使用的所有网络。

我的问题最终变成了 Robert评论:openvpn service openvpn stop 的问题“解决了”问题。

关于python - docker "ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43720339/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com