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
for 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
for 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
은 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
이 오류 메시지에 대한 도움말을 검색했지만 찾을 수 없습니다. 이 오류의 원인은 무엇입니까?
I've seen it suggested docker may be at its maximum of created networks. The command docker network prune
can be used to remove all networks not used by at least one container.
My issue ended up being, as Robert commented about: an issue with openvpn service openvpn stop
'solved' the problem.
I ran into this problem because I had OpenVPN running. As soon as I killed OpenVPN, docker-compose up
fired right up, and the error disappeared.
Following Peter Hauge's comment, upon running docker network ls
I saw (among other lines) the following:
NETWORK ID NAME DRIVER SCOPE
dc6a83d13f44 bridge bridge local
ea98225c7754 docker_gwbridge bridge local
107dcd8aa889 host host local
The line with NAME
and DRIVER
as both host
seems to be what he is referring to with "networks already created on your host". So, following https://gist.github.com/bastman/5b57ddb3c11942094f8d0a97d461b430, I ran the command
docker network rm $(docker network ls | grep "bridge" | awk '/ / { print $1 }')
Now docker-compose up
works (although newnym.py
produces an error).
I have the same problem. I ran docker system prune -a --volumes
, docker network prune
, but both either no helped me.
I use VPN, I turn off VPN and, after it, docker started normal and he can create a network. After all, You can enable VPN again
As other answers mentioned, Docker's default local bridge
network only supports 30 different networks (each one of them uniquely identifiable by their name). If you are not using them, then docker network prune
will do the trick.
However, you might be interested in establishing more than 30 containers, each with their own network. Were you interested in doing so then you would need to define an overlay
network. This is a bit more tricky but extremely well documented here.
I ran in this problem with OpenVPN working as well and I've found a solution where you should NOT stop/start OpenVPN server.
Idea that You should specify what exactly subnet you want to use. In docker-compose.yml
write:
networks:
default:
driver: bridge
ipam:
config:
- subnet: 172.177.57.0/24
That's it. Now, default
network will be used and if Your VPN did not assigned you something from 172.177.57.*
subnet You're fine.
I had an identical problem with the same error message but the solution with removal of unused docker networks didn't help me. I've deleted all non-default docker networks (and all images and containers as well) but it didn't help - docker still was not able to create a new network.
The cause of the problem was in network interfaces that were left after OpenVpn installation. (It was installed on the host previously.) I found them by running ifconfig
command:
...
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.2 P-t-P:10.8.0.2 Mask:255.255.255.0
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:75 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:84304 (84.3 KB) TX bytes:0 (0.0 B)
tun1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.2 P-t-P:10.8.0.2 Mask:255.255.255.0
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:200496 errors:0 dropped:0 overruns:0 frame:0
TX packets:148828 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:211583838 (211.5 MB) TX bytes:9568906 (9.5 MB)
...
I've found that I can remove them with a couple of commands:
ip link delete tun0
ip link delete tun1
After this the problem has disappeared.
- Check if any other container is running, If yes, do:
docker-compose down
If VPN is connected, then disconnect it and try again to up docker container:
docker-compose up -d container_name
You can try
$sudo service network-manager restart
Worked for me.
I encoutered the same problem, the reason why is that you reached the max of networks:
do an : docker network ls
Choose one to remove using: docker network rm networkname_default
TL;DR
Add
version: "3.7"
services:
web:
...
network_mode: "bridge"
Read about network_mode
in the documentation.
Long version
Disclaimer: I am not very knowledgeable about Docker networking, so the "solution" that worked for me is like a magic incantation and YMMV.
When I ran docker run my-image
the networking gave me no problems, but when I converted this command to a docker-compose.yml
file, I got the same error as the OP.
I read Arenim's answer and some other stuff on the internet that suggested to re-use an existing network.
You can find existing networks like this:
# docker network ls
NETWORK ID NAME DRIVER SCOPE
ca0415dfa442 bridge bridge local
78cbbda034dd host host local
709f13f4ce2d none null local
I wanted to reuse the default bridge
network, so I added
services:
web:
...
networks:
default:
external:
name: bridge
to the the root of my docker-compose.yml
(so not inside one of my services
, but at the root indentation).
I now got the following error:
ERROR: for your-container network-scoped alias is supported only for containers in user defined networks
This led met to this Docker Github issue, that plainly stated that I should add the network_mode
object to my docker-compose
:
version: "3.7"
services:
web:
...
network_mode: "bridge"
I was using Docker version 18.09.8
, docker-compose
version 1.24.1
and the compose file format 3.7
.
This happened to me because I was using OpenVPN
. I found a way that I don't need to stop using the VPN or manually add a network to the docker-compose file nor run any crazy script.
I switched to WireGuard
instead of OpenVPN
. More specifically, as I am running the nordvpn solution, I installed WireGuard and used their version of it, NordLynx.
I fixed this issue by steps :
turn off your network (wireless or wired...).
reboot your system.
before turning on your network on PC, execute command docker-compose up, it's going to create new network.
then you can turn network on and go on ...
'developer tip' 카테고리의 다른 글
목록 내에서 고유 한 값을 계산하는 방법 (0) | 2020.09.08 |
---|---|
Mac에 jmeter를 어떻게 설치합니까? (0) | 2020.09.08 |
UIView 바운스 애니메이션을 만드는 방법은 무엇입니까? (0) | 2020.09.08 |
iPhone에서 URL을 확인하는 방법 (0) | 2020.09.08 |
iOS 7-기본 뷰 컨트롤러 인스턴스화 실패 (0) | 2020.09.08 |